Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.