I assure you that PHP preg_* functions are working properly. You are
experiencing an issue with escaping -- please try using this expression:
/('(([^']*\\\\')*)([^']*)')
On Tue, 18 Sep 2001, Grzegorz Prokopski wrote:
> Hi !
>
> I found that following regular expression patern:
> /('(([^']*\\')*)([^']*)')/s
>
> works in Perl, but doesn't in PHP.
>
> It is trying to find sting with ' char escaped, like 'It wasn\'t so good'
>
> You may test it with following scripts :
>
> #!/usr/bin/perl
> while (<>)
> {
> print ">$1<\n" while /('(([^']*\\')*)([^']*)')/gs
> }
>
> while such code in PHP 4.0.6:
> <?php
> $s_test = " 'abc \' aaa' sfds' ' sdfsdfsdfsd' ";
> $s_re = <<< EOT
> /('(([^']*\\')*)([^']*)')/s
> EOT;
> if (preg_match($s_re, $s_test, $as_result)) {
> print_r($as_result);
> } else echo "expression not found\n";}
>
> will return You ALL the string $s_test between first occurence of
> ' char and the last occurence.
>
> I've been told on #php at irc.php.net that perl regexp handling code
> is a part of PHP source and so this effect is not related to bugs of
> some external library.
>
> Is there anything I can do about it ?
> I wanted to create PHP shell script that parses other scripts looking
> onto their code structure and fetching some info from it.
>
> Further I want to properly parse strings like: 'some \\\' single\n\' string'
> which seems to be just impossible to be done today.
>
> And I really wouldn't like to switch to Perl.
> Is there any hope ? :-)
>
> Waiting for Your answers.
>
> Grzegorz Prokopski
>
> System: Debian Potato with some addons from Woody
> (but nothing so significant that could affect results - I think)
>
>
>
> --
> PHP Development Mailing List <http://www.php.net/>
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
-Andrei
If you find a job that you love, you'll
never work another day in your life.
- Mark Jackson
--
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]