Regular Expression: find all links and souround them with an A-tag (PHP)

// Convert links with [protocol]://...
$content = preg_replace('/(((f|ht){1}tp(s)?:\/\/)[-a-zA-Z0-9@:%_\+.~#?&\/\/=]+)/i',
'<a href="\\1"' . $attributesString . '>\\1</a>', $content);

// Convert links without [protocol]://...
$content = preg_replace('/([[:space:]()[{}])(www.[-a-zA-Z0-9@:%_\+.~#?&\/\/=]+)/i',
'\\1<a href="http://\\2"' . $attributesString . '>\\2</a>', $content);

// Convert mail address
$content = preg_replace('/([_\.0-9a-z-]+@([0-9a-z][0-9a-z-]+\.)+[a-z]{2,3})/i',
'<a href="mailto:\\1"' . $attributesString . '>\\1</a>', $content);