dakire Posted December 14, 2006 Share Posted December 14, 2006 I've been testing everything and can't get it work properly.I want to rip everything between [b]<span class="brodtext">[/b] and [b] <div class="byline">[/b] into backreference 1 with preg_match_all.[code] <span class="brodtext"> <tt> </tt> På den officiella sajten are2007.com finns information om själva VM, om artister, biljetter och andra praktiska upplysningar för den intresserade.<br /> <div class="byline">[/code]I've triede these without success:[code]/<span class="brodtext">((?:[\r\n]|.)*?)<div class="byline">/smU/<span class="brodtext">([.\r\n]*?)<div class="byline">/smU[/code]And a LOT of variations.Please help me. Quote Link to comment https://forums.phpfreaks.com/topic/30590-get-all-data-between-two-tags/ Share on other sites More sharing options...
Orio Posted December 14, 2006 Share Posted December 14, 2006 Try this:[code]<?php$regex = "/<span class=\"brodtext\">(.*?)<div class=\"byline\">/"preg_match_all($regex, $text, $matches);print_r($matches[0]);?>[/code]Orio. Quote Link to comment https://forums.phpfreaks.com/topic/30590-get-all-data-between-two-tags/#findComment-141085 Share on other sites More sharing options...
HuggieBear Posted December 14, 2006 Share Posted December 14, 2006 Slight variation on what Orio's got...Based on what you've posted, I'd go with this...[code]<?php$pattern = "/<span class=\"brodtext\">(.*?)<div class=\"byline\">/s";preg_match_all($pattern, $text, $matches);print_r($matches);?>[/code]The /s modifier allows you to include whitespace and newlines as characters matched by the '.' (period).RegardsHuggie Quote Link to comment https://forums.phpfreaks.com/topic/30590-get-all-data-between-two-tags/#findComment-141129 Share on other sites More sharing options...
dakire Posted December 15, 2006 Author Share Posted December 15, 2006 Thanks A LOT HuggieBear, works fine! Quote Link to comment https://forums.phpfreaks.com/topic/30590-get-all-data-between-two-tags/#findComment-141560 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.