note 15863 deleted from function.preg-replace by jimw
| From: | jimw@php.net | Date: | Thu, 20 Dec 2001 23:28:51 +0000 |
| Subject: | note 15863 deleted from function.preg-replace by jimw | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-23563@lists.php.net to get a copy of this message | ||
To use custom URL tags, so you can disallow the rest of the html tags (using htmlspecialchars() or
htmlentities()), I wrote the following:
$pattern = "/(\[URL=\\\\\")(.*?)(\\\\\"\])/i";
$replace = "<a href=\"\\2\">";
$String = preg_replace($pattern, $replace, $String);
$String = eregi_replace("(\[/URL\]){1}", "</a>", $String);
this will replace [url="http://www.something.com"]Something.com[/url]
with
<a href="http://www.something.com">Something.com</a>