$regstr = "https?://[a-zA-Z0-9.-]{2,}(:[0-9]+)?(/[_.!~*a-zA-Z0-9;/?:@&=+$,%#-]+)?/?"; $string = preg_replace($regstr,"\\0", $string); $regstr = "([a-zA-Z0-9_\.-]+\@)([a-zA-Z0-9_\.-]+)([a-zA-Z]+)"; $string = preg_replace($regstr, "\\1\\2\\3", $string); $regstr = "\(?([0-9]{1,4})\)?[-. ]?([0-9]{1,4})[-. ]?([0-9]{3,4})"; $string = preg_replace($regstr, "\\0", $string);