Jump to content

Optional RegEx Grouping Fails


carpiediem

Recommended Posts

This returns a result:

preg_match('/Results[\s\S]+?(?:<\/p)/', $this->rawText, $match);

 

and this matches the same text (plus the remainer of the rawText string):

preg_match('/Results[\s\S]+?/', $this->rawText, $match);

 

But, this doesn't give me a match at all:

preg_match('/Results[\s\S]+?(?:<\/p)?/', $this->rawText, $match);

 

Why isn't the question mark at the end working the way I expect it to?  Thanks.

Link to comment
https://forums.phpfreaks.com/topic/216325-optional-regex-grouping-fails/
Share on other sites

  • 2 weeks later...

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.