|
Posted by Terence on 05/24/07 23:24
I've been puzzling over something for ages and now give up:
Does anyone see any problem with any of the following:
$line = preg_replace('/\[#([A-Fa-z0-9]{1,6})\]/i', "<font color='#
${1}'>", $line);
$line = preg_replace('/\[(#(([A-Fa-f0-9]){3}(([A-Fa-f0-9]){3})?))\]/
i', "<font color='#${1}'>", $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 \\1 for the backreferencing, or even \\0 just to test
- but even that doesn't work.
Is it possible that backreferencing can just be turned off?!?
- Terence
[Back to original message]
|