note 10287 added to eregi_replace
| From: | nerdyguy at worldonline dot dk | Date: | Sun, 24 Dec 2000 22:49:39 +0000 |
| Subject: | note 10287 added to eregi_replace | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-9065@lists.php.net to get a copy of this message | ||
I wrote a function to highlight these as url's:
ftp://bruger@www.minhost.dk
ftp://bruger:kodeord@www.minhost.dk
http://www.minhost.dk/minside.php?id=1
http://www.minhost.dk/minside.php?id=1&bruger=mig
Try this:
Function validateURL ( $result ) {
$result =
eregi_replace("((ftp://)|(http://)|(www))(([a-z0-9.\-])*)(@)?(([a-z0-9\.])*)(([:/])?)((([a-z0-9]*)(@?)/*)+([.a-z]{2,4}){1})?((\??[a-z0-9\=]*)?)((\&[a-z0-9\=]*)?)(([\.a-z]){2,4})?",
"<a href=\"\\0\" onfocus=\"blur()\">\\0</a>",$result);
return $result;
}
$string = "a message that contains some url's";
$string = validateURL($string);
echo $string;
http://www.php.net/manual/function.eregi-replace.php