我得到的最多:
$name = str_replace("*.*", "✦", $name);
例如:
$name = "Hello | google.com"
将被替换为:
$name = "Hello | ✦"
答案 0 :(得分:0)
尝试使用regex
<?php
preg_replace('/\b(?:(?:https?|ftp|file):\/\/|www\.|ftp\.)[-A-Z0-9+&@#\/%=~_|$?!:,.]*[A-Z0-9+&@#\/%=~_|$]/i','✦',$name);
?>
答案 1 :(得分:0)
您可以使用preg_replace()
进行模式匹配替换。
$name = "Hello | google.com";
//$name = preg_replace("/[a-zA-Z]+\.[a-zA-Z]+/", "✦", $name);
$name = preg_replace("/((http|https)\:\/\/)?[a-zA-Z0-9\.\/\?\:@\-_=#]+\.([a-zA-Z0-9\&\.\/\?\:@\-_=#])+/", "✦", $name);
echo $name;