Posted by lawrence k on 09/29/47 12:01
I wanted to take some input and change it so that all the plain text
URLs got wrapped in HTML hyperlinks. I found a bit of preg_replace on
this site, which I thought I could use:
http://www.roscripts.com/PHP_regular_expressions_examples-136.html
Sad to say, I've not been able to get that code to work. Here is what
I'm doing:
$message = addslashes($message);
$message = htmlentities($message);
$message = preg_replace('\b(https?|ftp|file)://[-A-Z0-9+&@#/%?
=~_|!:,.;]*[-A-Z0-9+&@#/%=~_|]','<a href="\0">\0</a>', $message);
Here is the error that I'm getting:
Warning: preg_replace(): Delimiter must not be alphanumeric or
backslash in
/var/www/vhosts/cyberbitten.com/httpdocs/sharedCode/
addNewChatMessage.php on
line 42
Can anyone tell me what I'm getting wrong here?
[Back to original message]
|