Hello Everyone,
I have BB Codes in my website. People can use the "link" BB code which obviously makes links and can customize what you click (<a href="">THIS</a>). Now if somebody just wants to paste a link and does not care about the above then the link is auto linked which I can do using:
$reg_exUrl = '/(?<!(\[link=)|(\[img\]))(http|https|ftp|ftps)\:\/\/[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(\/\S*)?/i';
preg_match_all($reg_exUrl, $string, $matches);
$usedPatterns = array();
foreach($matches[0] as $pattern){
if(!array_key_exists($pattern, $usedPatterns)){
$usedPatterns[$pattern]=false;
$string = str_replace($pattern, '[link='.$pattern.']'.$pattern.'[/link]', $string);
}
}
However the above code conflicts with the BB code array that i'm using and I think it adds more link tags even to the current [link=][/link] tags
So, i want the string to only auto link urls that do not begin with [link= and end with [/link] and im assuming this is using regEx but I am hopeless with it.
Thank you in advance!
Judgey