| re: "Ereg_replace" regular expression woes
Rob Pridham wrote:[color=blue]
> $string = eregi_replace(" ((http|https|rtsp)://[^[:space:]]+[[:alnum:]/])","
><a href=\"\\1\">\\1</a>", $string);
>
> That almost works well enough, but I need to add some more conditions. The
> output CANNOT contain the words:
>
> & q u o t ;
> & g t ;
> & l t ;
>
> (ignore the spaces). If it does find those things it should break off, just
> like when it finds a space. So far attempts to add this in have been
> completely fruitless. Help would be very much appreciated![/color]
I think your best bet is to search for the forbidden content directly
and not within a regular expression.
Do the eregi_replace and then test for the forbidden content, maybe with
something like:
<?php
// ... including the eregi_replace()
if (strpos($string, '"') !== false) die('broken URL');
if (preg_match('/&[gl]t;/', $string)) die('broken URL');
// ...
?>
--
--= my mail box only accepts =--
--= Content-Type: text/plain =--
--= Size below 10001 bytes =-- |