I want to match a url link in wall post and replace this link with anchor tag, for this I use the regular expression below.
I would like the match 4 types of url:
This works great for me - including mailto check:
function LinkIt($text) { $t = preg_replace("/(\b(?:(?:http(s)?|ftp):\/\/|(www\.)))([-a-züöäß0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|])/im", '$1$4', $text); return preg_replace("/([\w+\.\-]+@[\w+\-]+\.[a-zA-Z]{2,4})/im", strtolower('$1'), $t); }