Reply to preg_replace backreferencing problem

Your name:

Reply:


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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация