Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
- preg_replace backreferencing problem
May 24, 2007, 11:24 pm
rate this thread
Does anyone see any problem with any of the following:
$line = preg_replace('/\[#([A-Fa-z0-9])\]/i', "<font color='#
$line = preg_replace('/\[(#(([A-Fa-f0-9])(([A-Fa-f0-9]))?))\]/
i', "<font color='#'>", $line);
I tried both ; both don't work.
This snippet should convert something like [#FF0000] (hex colours)
into an HTML font tag. I believe the reg.exp IS matching (since I do
get a <font> tag), but the backreferencing is not working since the
font tag would contain an empty hex code.
I've tried using for the backreferencing, or even just to test
- but even that doesn't work.
Is it possible that backreferencing can just be turned off?!?