Shanti Posted August 29, 2006 Share Posted August 29, 2006 Hello, lets say I got this HTML File:<!-- Start Code -->some html herewithlots of diferent chars < , > \ / etc etc<!-- End Code -->some other stuff here more html <!-- Start Code -->some html herewithlots of diferent chars < , > \ / etc etc<!-- End Code -->how do i make it so that I can match anything between <!-- Start Code --> and <!-- End Code --> in the whole html file? this example should give me 2 matchesits driving me nuts been trying for a couple days with no succes, this is what i have[code]<!-- Start Code -->[\+;\|\=\:\-\!\.\<\,\>\\\'\"\/\w\s]+<!-- End Code -->[/code]but this will make 1 match including everything out of those delimiters :-\any ideas?ThanksShanti Castillo G. Link to comment https://forums.phpfreaks.com/topic/18961-selecting-between-2-delimiters/ Share on other sites More sharing options...
rea|and Posted August 30, 2006 Share Posted August 30, 2006 In this case I guess you have to use the ungreedy local modifier "?" to force the pattern to stop after the first occurrence of whatever your delimiter is. Something like:[code]/<!-- Start Code -->(.*?)<!-- End Code -->/s[/code]Use preg_match_all if you want returned each match and not only the first one. Link to comment https://forums.phpfreaks.com/topic/18961-selecting-between-2-delimiters/#findComment-82720 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.