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
https://forums.phpfreaks.com/topic/181855-solved-preg_match-and-googling-code/
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.