Forum Moderators: coopster

Message Too Old, No Replies

Converting a perl regular expression to php

please help...

         

irubin

4:40 pm on Aug 1, 2003 (gmt 0)

10+ Year Member



Hello,

I have the following perl regular expression that return a string with two HTML comments, that is:

$content = "<!-- DETAILS BEGIN -->this is my string<!-- DETAILS END -->";

($string) = $content =~ /<!--\s*DETAILS\s+BEGIN\s*-->\s*(.*?)\s*<!--\s*DETAILS\s+END\s*-->/gs;

How can this be converted to php?

Any help will be appreciated.

-R

Timotheos

7:16 pm on Aug 1, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'm lowsy with reg ex but I think the preg functions are compatible with perl regex. Check out preg_match()

vincevincevince

7:55 pm on Aug 1, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member




$content = "<!-- DETAILS BEGIN -->this is my string<!-- DETAILS END -->";

preg_match("/<!--\s*DETAILS\s+BEGIN\s*-->\s*(.*?)\s*<!--\s*DETAILS\s+END\s*-->/s",$content,$match);

echo $match[1];