General Community > Scripting Help
BB-code regex help needed!
Curbow 5:
I use the following coding for [ size ] and [ color ] bb-code:
--- Code: ---$message = eregi_replace("\\[size=([^\\[]*)\\]([^\\[]*)\\[/size\\]","<span style=\"font-size: \\1px;\">\\2</span>",$message);
$message = eregi_replace("\\[color=([^\\[]*)\\]([^\\[]*)\\[/color\\]","<font color=\"\\1\">\\2</font>",$message);
--- End code ---
When I input the following bb-codes, only the first one really works, the second one only works for the [ color ] and the other two don't do anything:
--- Code: ---[color=red][size=18]test[/size][/color]
[size=18][color=red]test[/color][/size]
[size=18][color=red]test[/size][/color]
[color=red][size=18]test[/color][/size]
--- End code ---
I don't really understand what the problem is... If anyone is willing to take a look at the coding and tell what I did wrong, I'd be really gratefull! :D
Shadow:
Just wondering, why don't you just use the <font> tag for the size? :-/
Curbow 5:
i'm not quite sure.... but would it make a difference?
Chris Cromer:
Less html... but other than that no.
Spaceman-Spiff:
ereg and eregi are much slower than preg
if you can, you should use preg_replace instead
Navigation
[0] Message Index
[#] Next page
Go to full version