Topic: perl -> php regex

code:

if (preg_match('/^diff -urN punbb_vanilla\/(.*) punbb_____mod\/\1$/', $diff_urN[$dln]))
{
    # Grab the filename
    $fname = ${1};
    print '$fname:'.$fname;
} else print 'I love perl... but I #$@% php regex';

output:

$fname:

What am I doing wrong here? please don't tell me I have to use the match array X.X Anyone even know why they call it a perl compatible regex? Couldn't be further from the truth... tongue

echo "deadram"; echo; fortune;

Re: perl -> php regex

Moved to Programming

Re: perl -> php regex

deadram wrote:

What am I doing wrong here? please don't tell me I have to use the match array X.X

Well, that's what you have to do. PHP, as compared to Perl, does not store the result in some magic variable ${1}. You actually have to tell PHP where to store the results.

They call it Perl compatible regex because the syntax of the regular expression is compatible with that used in Perl (they both use the same library).

"Programming is like sex: one mistake and you have to support it for the rest of your life."

Re: perl -> php regex

Yah, I've perty much given up on the preg set from php... The comparison code I'm using now is what you'd expect to see in C code. Using things like ($str[0] == 'c') for the most part. php's string handling functions are so darned weak ;.; They should just give us raw access to pointers, so we can actually write efficient code XD

echo "deadram"; echo; fortune;

Re: perl -> php regex

deadram wrote:

They should just give us raw access to pointers, so we can actually write efficient code XD

for php? i dont think so. prove something where direct access to pointers in php will be a benefit...

~thegleek

Re: perl -> php regex

Erm... name it? For starters, I could actually use something that resembles perl regex tongue Array handling. Doing RLE on  data to "bypass" the memory limits of php.

php is a great tool to make a counter on your website, It's not a great tool to handle any amount of data larger then the average e-mail (without attachments tongue).

echo "deadram"; echo; fortune;

Re: perl -> php regex

deadram wrote:

Erm... name it? For starters, I could actually use something that resembles perl regex tongue Array handling. Doing RLE on  data to "bypass" the memory limits of php.

php is a great tool to make a counter on your website, It's not a great tool to handle any amount of data larger then the average e-mail (without attachments tongue).

ok TROLL... and thats why the entire punBB is coded in PHP, cuz it all it does is count webpage hits right? yeah.

~thegleek