dbo Posted June 30, 2009 Share Posted June 30, 2009 I'm trying to parse some data out of a large HTML string. When I try this with the full HTML document it fails to find a match yet if I take a paragraph (which contains the search string) and hard code this block I'm able to find a match. Is there an issue with searching large strings or am I missing something? Quote Link to comment https://forums.phpfreaks.com/topic/164281-regular-expression-wont-work-on-a-longer-string/ Share on other sites More sharing options...
rhodesa Posted June 30, 2009 Share Posted June 30, 2009 You are probably missing something...can you give an example? Quote Link to comment https://forums.phpfreaks.com/topic/164281-regular-expression-wont-work-on-a-longer-string/#findComment-866607 Share on other sites More sharing options...
Maq Posted June 30, 2009 Share Posted June 30, 2009 This shouldn't be the solution but try including the greedy (g) and multi line (m) flags. Quote Link to comment https://forums.phpfreaks.com/topic/164281-regular-expression-wont-work-on-a-longer-string/#findComment-866611 Share on other sites More sharing options...
dbo Posted June 30, 2009 Author Share Posted June 30, 2009 I believe it was the multiline problem, though I didn't use the m modifier. Perhaps I'll experiment more. Ultimately what I ended up doing was making my search pattern a bit more generic by using .* in a couple of places to eat whatever may exist. Quote Link to comment https://forums.phpfreaks.com/topic/164281-regular-expression-wont-work-on-a-longer-string/#findComment-866612 Share on other sites More sharing options...
Maq Posted June 30, 2009 Share Posted June 30, 2009 I believe it was the multiline problem, though I didn't use the m modifier. Perhaps I'll experiment more. Ultimately what I ended up doing was making my search pattern a bit more generic by using .* in a couple of places to eat whatever may exist. If that's the case then add the 's' modifier to include newlines instead of .*, which is what I think you're doing. http://www.php.net/manual/en/reference.pcre.pattern.modifiers.php Quote Link to comment https://forums.phpfreaks.com/topic/164281-regular-expression-wont-work-on-a-longer-string/#findComment-866617 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.