maxudaskin Posted August 8, 2012 Share Posted August 8, 2012 I'm looking to find a a starting and ending phrase and return the text in between. %\{\{items\}\}(.*?)\{\{\/items\}\}% I'm looking for {{items}} and {{/items}}. Anything in between, possibly multiple lines, should be returned ($1?). For some reason, it returns 0 results with the following... <div id="items"> {{items}} <div class="item"> <table> <tr> <td>{{item_number}}</td> <td class="text_right">{{currency}} {{item_extension}}</td> </tr> <tr> <td colspan="2">{{item_units}} at {{item_cost_per_unit}}</td> </tr> </table> {{item_description}} </div> {{/items}} </div> Quote Link to comment https://forums.phpfreaks.com/topic/266794-poisex-regex-assistance/ Share on other sites More sharing options...
requinix Posted August 8, 2012 Share Posted August 8, 2012 dot-all (a period) normally doesn't match newline characters. POSIX you say? Then that means you're using the ereg family of functions. Those are deprecated; you should be using the PCRE functions. preg_match_all('%\{\{items\}\}(.*?)\{\{/items\}\}%s', $text, $matches); The /s flag (or in this case %s) is what tells preg_match_all() that the dot-all should include newlines. Quote Link to comment https://forums.phpfreaks.com/topic/266794-poisex-regex-assistance/#findComment-1367712 Share on other sites More sharing options...
maxudaskin Posted August 8, 2012 Author Share Posted August 8, 2012 Gah, I guess it's better I switch over now, before I get too far into the script. Thank you --- Also, it worked. Quote Link to comment https://forums.phpfreaks.com/topic/266794-poisex-regex-assistance/#findComment-1367714 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.