Page 1 of 1

ereg_replace help

Posted: Sun Feb 02, 2003 1:41 pm
by hob_goblin
Okay, I've always been bad at reg exp's but here is my problem;

I use the code:

Code: Select all

$data = eregi_replace("\їcolor=(ї#a-fA-F0-9]{7}|їa-zA-Z]*)\](.*)\ї/color\]",
   "<span style="color:\\1;background-color:transparent">\\2</span>", $data);
so if i type in [ color=red ]something[ /color ] (wihout spaces), it will turn the text red..

but now, if i type [ color=red ] this should be red [ /color ][ color=blue ] this should be blue [ /color ] (without spaces), it all turns out red...

i know i should be changing the (.*) to somethign else, but i just can't grasp what.

Posted: Sun Feb 02, 2003 6:32 pm
by Kriek
I am seriously beginning to loath regular expressions, although I use them almost everyday.
Check your meta-characters (.*) I believe you want to do (.*?) instead.