plznty Posted November 6, 2009 Share Posted November 6, 2009 <?php $s = file_get_contents("page.html"); preg_match('/<div class="brown_box main_ge_page vertically_spaced"><div class="subsectionHeader">(.*)<\/div>/', $s, $m); echo $m[1]; ?> page.html content <div class="brown_box main_ge_page vertically_spaced"> <div class="subsectionHeader"> Works </div> How come it doesnt get the word, "Works". Thank you Link to comment https://forums.phpfreaks.com/topic/180496-solved-preg_match-logical-error/ Share on other sites More sharing options...
thebadbad Posted November 6, 2009 Share Posted November 6, 2009 Because there's a line break between the two divs. Try to add \s* between them, and you should also make your quantifier lazy by adding a question mark after .* (stopping the match at the first encountered </div> character sequence, not the last). Link to comment https://forums.phpfreaks.com/topic/180496-solved-preg_match-logical-error/#findComment-952201 Share on other sites More sharing options...
plznty Posted January 10, 2010 Author Share Posted January 10, 2010 Dont worry fixed Link to comment https://forums.phpfreaks.com/topic/180496-solved-preg_match-logical-error/#findComment-992124 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.