Jump to content

Reg ex


ToonMariner

Recommended Posts

Each time I think I get these something happens which indicates i dont.

OK I have a html file that a place contents into a string using file_get
_contents.

now I want to return from the string everything from '<center><br>' upto and including '</textarea>' which have tags inbetween and newlines etc. etc.

Now I have tried

preg_match('/<center><br>.\s*<\/textarea>/', $string, $outstr);

preg_match('/<center><br>(?!<\/textarea>).\s*<\/textarea>/', $string, $outstr);

and some other embarrassing combinations.

Bit of help would be very much appreciated.
Link to comment
https://forums.phpfreaks.com/topic/10914-reg-ex/
Share on other sites

try this:
preg_match("/<center><br>.*?<\/textarea>/",$string, $outstr);

$outstr[0] will contains everything between but not included '<center><br>' and '</textarea>'

pregmatch is non greedy and it will stop at the first </textarea>.
Also, you need to use double quote to specify the pattern string. PHP will not parse escape char with single quote.

Tom
Link to comment
https://forums.phpfreaks.com/topic/10914-reg-ex/#findComment-40783
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.