carpiediem Posted October 20, 2010 Share Posted October 20, 2010 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. Quote Link to comment https://forums.phpfreaks.com/topic/216325-optional-regex-grouping-fails/ Share on other sites More sharing options...
mikecampbell Posted October 28, 2010 Share Posted October 28, 2010 Hmm, works fine for me. Can you provide an example that matches in the first two cases but not the third? Quote Link to comment https://forums.phpfreaks.com/topic/216325-optional-regex-grouping-fails/#findComment-1127454 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.