我试图替换字符串中的一个或两个字母。请考虑这个正则表达式正则表达式替换一个或两个字母的单词
$str = 'I haven\'t got much time to spend!';
echo preg_replace('/\b([a-z0-9]{1,2})\b/i','',$str);
returns: haven' got much time spend!
expected output: haven't got much time spend!
我的目标是从字符串中删除任何一个或两个字符长度的单词。这可以是字母数字或特殊字符。
字符串'foo a,bb,bar:cc zz.'那么期望的结果是什么? – Qtax