Jump to content

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
Link to comment
https://forums.phpfreaks.com/topic/11939-eregi-to-preg_match/
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.
Link to comment
https://forums.phpfreaks.com/topic/11939-eregi-to-preg_match/#findComment-45324
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]
Link to comment
https://forums.phpfreaks.com/topic/11939-eregi-to-preg_match/#findComment-46424
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.