note 14770 deleted from function.eregi-replace by jimw
| From: | jimw@php.net | Date: | Fri, 02 Nov 2001 02:08:49 +0000 |
| Subject: | note 14770 deleted from function.eregi-replace by jimw | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-20248@lists.php.net to get a copy of this message | ||
Hello everyone:
I'd just like to contribute two code snippets. This took me a LONG time to come up with
because I am not an experienced programmer.
Anyway, I am making a chat program and I wanted the user input to automatically replace any URLs and
email addresses with links on the chat screen, so I used the following:
$message =
eregi_replace("([a-zA-Z]+)://([a-zA-Z0-9\._-]+)(\.[a-zA-Z]+)","<strong><a
href=\"\\1://\\2\\3\"
target=\"_blank\">\\1://\\2\\3</a></strong>", $message);
$message = eregi_replace("([a-zA-Z0-9_-]+)@([a-zA-Z0-9\._-]+)(\.[a-zA-Z]+)",
"<strong><a href=\"mailto:\\1@\\2\\3\">\\1@\\2\\3</a></strong>",
$message);
Jake