On Wed, September 20, 2006 11:20 am, Pawel Miroslawski wrote:
> Hi
> it's example script:
>
> <?php
> $string = "This is some _color:pink_ colored text _color_";
>
> $patterns[0] = '/_color:(.*?)_/';
> $patterns[1] = '/_color_/';
> $replacements[0] = '<font color="$1">';
> $replacements[1] = '</font>';
>
> echo preg_replace($patterns, $replacements, $string);
> ?>
>
> It should be ok, but i don't test it.

For the sanitization...

.*? could be something more like:  [#a-z0-9A-Z]+

The # assumes you want to allow #ff0000 style colors.

Since this whitelists the specific characters you allow, it's probably
better than the strip_tags thing.

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to