Connecting Tech Pros Worldwide Forums | Help | Site Map

Converting PERL regular expression to PHP?

Con
Guest
 
Posts: n/a
#1: Sep 28 '05
Hi, I'm in the process of converting some PERL to PHP. Thus, is it
possible to leave the following line as is:

if ($id =~ /vvvvv/g) {

...

}

If not, can someone provide PHP equivalent? BTW, I have checked the
syntax using 'php -l' because I'm not an expert of PERL but I'm using
various references to do the conversion. However, I was able to locate
this particular construct.

Thanks in advance,

-Conrad


Con
Guest
 
Posts: n/a
#2: Sep 28 '05

re: Converting PERL regular expression to PHP?


Hi, the last couple of sentences should read:

If not, can someone provide PHP equivalent? BTW, I have checked the
syntax using 'php -l'. Also, I'm not an expert of PERL but I'm using
various references to do the conversion. However, I wasn't able to
locate
this particular construct.

Thanks again,

-Conrad

Sven Lauritzen
Guest
 
Posts: n/a
#3: Sep 28 '05

re: Converting PERL regular expression to PHP?


Am Dienstag, den 27.09.2005, 17:17 -0700 schrieb Con:[color=blue]
> Hi, I'm in the process of converting some PERL to PHP. Thus, is it
> possible to leave the following line as is:
>
> if ($id =~ /vvvvv/g) {[/color]

The php equivalent is

if(preg_match('/vvvvv/', $id)) {

I'm quite sure that you won't need the "g".

See
http://www.php.net/manual/en/function.preg-match.php

Best regards

Sven
--
Sven Lauritzen
--------------------------------------------------------------------
mailto: the minus pulse at gmx dot net

pub 1024D/95C9A892 sub 1024g/D30E490F ABCDEFGHIJKLM
Fp 2FA9 FC9B 078C 5BC7 87DC 0B0D 2329 94F6 95C9 A892 NOPQRSTUVWXYZ
--------------------------------------------------------------------

Closed Thread