Monkeymatt Posted June 14, 2006 Share Posted June 14, 2006 How do I convert this eregi matching to preg, it works in eregi, but I can't get it to work in preg:[code]eregi("<{loop_".$section."}>(.*)<{/loop_".$section."}>", $this->level_tracker[$i]['****code****'], $contents);[/code]Here is the preg_match I tried, which does not work:[code]preg_match('|<{loop_'.$section.'}>(.*)<{/loop_'.$section.'}>|iU', $this->level_tracker[$i]['****code****'], $contents);[/code]Any help would be appreciated.Monkeymatt Quote Link to comment https://forums.phpfreaks.com/topic/11939-eregi-to-preg_match/ Share on other sites More sharing options...
poirot Posted June 14, 2006 Share Posted June 14, 2006 I am not familiar with ereg, but what is your problem?I mean, what are you trying / failing to do? Quote Link to comment https://forums.phpfreaks.com/topic/11939-eregi-to-preg_match/#findComment-45316 Share on other sites More sharing options...
Monkeymatt Posted June 14, 2006 Author Share Posted June 14, 2006 $this->level_tracker[$i]['****code****'] is the data from a template file. I want to be able to pull all the stuff out of between <{loop_(section name)}> and <{/loop_(section name)}> not matter what is in there. Currently, preg is not matching any of the sections for me. Quote Link to comment https://forums.phpfreaks.com/topic/11939-eregi-to-preg_match/#findComment-45324 Share on other sites More sharing options...
Wildbug Posted June 16, 2006 Share Posted June 16, 2006 Two things: Try the 's' modifier so the period (.) matches newlines, too. Secondly, are the curly braces part of the text you're trying to match? If so, try escaping them (although it shouldn't matter -- I bet the newline thing is holding you up).[code]preg_match( '|<{loop_'.$section.'}>(.*)<{/loop_'.$section.'}>|iUs', // <-- note 's' modifier $this->level_tracker[$i]['****code****'], $contents);[/code] Quote Link to comment https://forums.phpfreaks.com/topic/11939-eregi-to-preg_match/#findComment-46424 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.