phpbar.de logo

Mailinglisten-Archive

[php] preg-replace problem

[php] preg-replace problem

Christian Hamacher php_(at)_phpcenter.de
Sun, 5 Aug 2001 12:26:08 +0200


> |CODE-SCHNIPSEL AN|
>
> function replace_uri($str) {
>   $pattern =
> '#(^|[^\"=]{1})(http://|ftp://|mailto:|news:)([^\s<>]+)([\s\
> n<>]|$)#sm';
>   return preg_replace($pattern,"\\1<a
> href=\"\\2\\3\"><u>\\2\\3</u></a>\\4",$str);
> }
>
> $text = "http://www.pcmag.de, mailto:david_(at)_pcmag.de";

$text = replace_uri ($text);


> echo $text;
>
> |CODE-SCHNIPSEL AUS|

Gruß
  Christian



php::bar PHP Wiki   -   Listenarchive