我想删除四个或更多问号。
我现在正在使用它:
preg_replace( '{\\?+}', '', $text );
但这确实删除了所有问号。
答案 0 :(得分:1)
// Use {4,} to indicate 4 or more of the preceding thing
$pattern = '~\?{4,}~';
$str = "I have 3??? and that isn't enough";
$str2 = "I have 5????? and that is enough";
// Won't replace only 3 ?
echo preg_replace($pattern, '', $str);
// I have 3??? and that isn't enough
// Will replace 5 ?
echo preg_replace($pattern, '', $str2);
// I have 5 and that is enough