I built another forum and am trying to correct an issue I have had in others...I have always looked for URLs that start with [url]http://[/url] and autolink them. No prob:
preg_replace("/(http:\/\/+.[\s]+)/i",'<a href="\1">\1</a>', $body);
No, reg exp is not my strongest skill, however, what I want to do is find URL's that start with [url]http://[/url] or www. (but not catch the same URL twice such as if it is http://www.
That should be a pieceof cake for somebody that knows reg exp better than I...now the tricky one...
In addition I want to scan a URL's length if it's over a given length, take some of the front and the back of the string, put a "..." in the middle and link it...I tried this:
$url=preg_match("/(http:\/\/+.[\s]+)/i", $input);
if(strlen($url) > 50)
{
$display_url=substr($url,40)."...".substr($url,-7);
}
else
{
$diplay_url=$url;
}
$input=preg_replace("/$url/",'(<a href="$url" target="_blank">$diplay_url</a>)', $input);
as well as some preg_match_all loops and str_replace in different context, but none of them seem to work...can anyone help me?!