I need to retrieve content of <p> tag with given class. Class could be simplecomment or comment …
So I wrote the following code
preg_match("|(<p class=\"(simple)?comment(.*)?\">)(.*)<\/p>|ism", $fcon, $desc);
Unfortunately, it returns nothing. However if I remove tag-ending part (<\/p>) it works somehow, returing the string which is too long (from tag start to the end of the document) …
What is wrong with my regular expression?
Try using a dom parser like http://simplehtmldom.sourceforge.net/
If I read the example code on simplehtmldom’s homepage correctly
you could do something like this: