Jump to content


Photo

Regex problems


  • Please log in to reply
1 reply to this topic

#1 rendezvous123

rendezvous123
  • Members
  • Pip
  • Newbie
  • 4 posts
  • LocationNoob Town

Posted 13 March 2006 - 05:03 AM

Here's what i'm having trouble with:
$shout = ereg_replace('\\[color="(.*)"\\](.*)\\[/color\\]', '<font color="\\1">\\2</font>', $shout);
When, i test it, it works fine, until, another instance of it is found on the same line.
I submit this:
[color="blue"]text[/color]
It brings back this:
<font color="blue">text</font>

But, when I submit this:
[color="blue"]text[/color][color="blue"]text[/color]
It brings back this:
<font color="blue"]stuff[/color][color="blue">stuff</font>

How can i make it to bring back this?:
<font color="blue">text</font><font color="blue">text</font>

I've tried many things, but failed to get what i want...
TIA
Sometimes, searching before posting doesnt work.

#2 rendezvous123

rendezvous123
  • Members
  • Pip
  • Newbie
  • 4 posts
  • LocationNoob Town

Posted 13 March 2006 - 11:06 AM

Nevermind! I figured out how. I needed to negate a character. All works fine, now. :D
TIA
Sometimes, searching before posting doesnt work.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users