Jump to content

Regex to extract text till a full stop which is not inside tags


dpacmittal

Recommended Posts

I want to extract text till a fullstop or a question mark but they should not be inside a tag.

 

I did this:

preg_match("!(<.*?>)?.*?(\.|\?)!s",$string,$matches);
print_r($matches);

 

It worked for some pages, and didn't work for others.

Most of the times it extracts till a <a href=http://example.  stopping at the dot in web address.

 

Need some guidance on this.

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.