Jump to content

Archived

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

ToonMariner

Reg ex

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.

Share this post


Link to post
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

Share this post


Link to post
Share on other sites
Thanks for reply but unfortunately no joy there - output array is empty.

Any other suggestions?

Share this post


Link to post
Share on other sites
Try this...

preg_match("`<center><br>(.*)</textarea>`",$string,$outstr);

Share this post


Link to post
Share on other sites

×

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.