kisabelle
9/9/2014 - 9:55 PM

Regular Expressions

Regular Expressions

Add anchor tags to URLs in a string without messing with anchor tags that are already in that string

$convertedText = preg_replace( '@(?<![.">])\b(?:(?:https?|ftp|file)://|[a-z].)[-A-Z0-9+&#/%=~_|$?!:,.][A-Z0-9+&#/%=~_|$]@i', '\0', $originalText );