Jump to content

Preg_match unknown modifyer


olli460

Recommended Posts

Hello,

 

Im trying to write a little script for my forums i need to get the reply from my forums. Im trying this

 

$pattern = '/<span class="postbody">(.*?)</span>/gis';
preg_match($pattern, $post, $video);

 

However inside the stuff its grabbing there is stuff code like </p> etc and it keeps trying to use that as a modifier so i get the following error:

 

Warning: preg_match() [function.preg-match]: Unknown modifier 'p' in /home/roms43c/public_html/porn_grab.php on line 21

 

Does anyone know a way around this?

Link to comment
https://forums.phpfreaks.com/topic/179479-preg_match-unknown-modifyer/
Share on other sites

This should possibly have been in the Regex forum, but no matter. Because you used forward slash as the delimiters, you have to escape instances of it used in the string...

 

$pattern = '/<span class="postbody">(.*?)<\/span>/gis';

 

... the more common alternative though is to use different delimiters when working with HTML/paths.

 

$pattern = '~<span class="postbody">(.*?)</span>~gis';

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.