Jump to content

Archived

This topic is now archived and is closed to further replies.

Monkeymatt

eregi to preg_match

Recommended Posts

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

Share this post


Link to post
Share on other sites
I am not familiar with ereg, but what is your problem?

I mean, what are you trying / failing to do?

Share this post


Link to post
Share on other sites
$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.

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.