Jump to content

[SOLVED] preg_match and googling code


lard

Recommended Posts

Hi folks.  My question is two fold, firstly I'm trying to use preg_match to strip some data between 2 bits of code.  What I have so far is:

 


$string="<p>This is the bit that i want</p><p>I don't want this</p>";
preg_match('/<p>(.+)<\/p>/',$string,$match);

$new=$match[1];

echo $new;

 

Which produces

This is the bit that i want</p><p>I don't want this

 

How do I make it search for the first instance of </p> rather than the last?  I presume that the key lies in the (.+) part, which leads me to my next question.  I don't really know what (.+) means (got it from someone else's thread) so it's a struggle to figure it out.  Trying to google it is really no help - there are no results, just like with many similar things.  Does anyone know of good comprehensive (!!) lists of such things or much better, how to search for info on them.  I'm sure google must have covered this somehow but I can't figure it.

 

Any help much appreciated!

Link to comment
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.