PDA

View Full Version : Javascript PHPBB-like URL tag processing


xglclub
11-01-2010, 04:11 PM
Hi all!
I'm working on a php dynamic web page that has a element that let user write and their text is show in "real time" just javascript-processing the text & tags on a element.
I change the "b","u", and cheap dreamweaver tags between brackets (like phpbb style) to its html equivalent like "strong" ,"u", and so using javascript regexps.
Problem occurs when i need to process the URL tag, when taking URL from [URL=http://.....
How can i replace it to 'a href="http:/..." ' thing?
Thanks in advance

davidj
11-08-2010, 07:09 AM
This works though


function urlParse($url){

$patterns = array ('/\link (/i','/\]/i','/\[\/url/i');

$replace = array ('<a href="','>','</a');

$link = preg_replace($patterns, $replace, $url);

return $link;

}

echo urlParse('[url="http://codezenith.co.uk)');