murfy Posted December 16, 2013 Share Posted December 16, 2013 Hello I need help with this reg. exp. for preg_match_all @(?<=style=\"display: inline\">)\d{1,3}(?=\.?<)@ Subject: <span style="display: inline">113</span><span class="qazL">.</span><span style="display: inline">111</span Returns: array ( 0 => array ( 0 => '113', 1 => 30, ), ) Should return values 113 and 111 in the array. How to correct this? Tested here: http://www.functions-online.com/preg_match.html Link to comment https://forums.phpfreaks.com/topic/284795-regular-expression/ Share on other sites More sharing options...
murfy Posted December 16, 2013 Author Share Posted December 16, 2013 preg_match_all("@(?<=style=\"display: inline\">)\d{1,3}(?=\.?<)@", $subject, $matches, PREG_OFFSET_CAPTURE, 0); Should return values 113 , 30 and 111 , 96 in the array. How to correct this? Link to comment https://forums.phpfreaks.com/topic/284795-regular-expression/#findComment-1462452 Share on other sites More sharing options...
Psycho Posted December 16, 2013 Share Posted December 16, 2013 preg_match_all("#<span style=\"display: inline\"[^>]*>(\d*)#is", $subject, $matches, PREG_OFFSET_CAPTURE); echo "<pre>" . print_r($matches, 1) . "</pre>"; Output: Array ( [0] => Array ( [0] => Array ( [0] => 113 [1] => 0 ) [1] => Array ( [0] => 111 [1] => 68 ) ) [1] => Array ( [0] => Array ( [0] => 113 [1] => 30 ) [1] => Array ( [0] => 111 [1] => 98 ) ) ) Link to comment https://forums.phpfreaks.com/topic/284795-regular-expression/#findComment-1462458 Share on other sites More sharing options...
murfy Posted December 16, 2013 Author Share Posted December 16, 2013 I see no error in the code, the testing page (see link above) fails to print it correctly. Problem solved. Link to comment https://forums.phpfreaks.com/topic/284795-regular-expression/#findComment-1462463 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.