i want to check if a user has a domain or website in his name. Much times, user will make advertise for own or other sites on that way.
So i want to replace the URL than with *
I found that
$url = 'Testusername google.com';
$regex = "((https?|ftp)\:\/\/)?"; // SCHEME
$regex .= "([a-z0-9+!*(),;?&=\$_.-]+(\:[a-z0-9+!*(),;?&=\$_.-]+)?@)?"; // User and Pass
$regex .= "([a-z0-9-.]*)\.([a-z]{2,3})"; // Host or IP
$regex .= "(\:[0-9]{2,5})?"; // Port
$regex .= "(\/([a-z0-9+\$_-]\.?)+)*\/?"; // Path
$regex .= "(\?[a-z+&\$_.-][a-z0-9;:@&%=+\/\$_.-]*)?"; // GET Query
$regex .= "(#[a-z_.-][a-z0-9+\$_.-]*)?"; // Anchor
if(preg_match("/^$regex$/i", $url)) // `i` flag for case-insensitive
{
$url = str_replace($url, $url, '*');
echo $url;
return true;
} else {
echo $url;
}
It works good to find the url, but how to replace only the domain in that name to * and not everything?
So i want
Testusername *