$str = ' this is a test <a href ="#">test</a> ';
想用正则将test换为test2但要求不能更改A标签里的内容,求解决。。。
以a 开头匹配test就可以了。preg_replace('/a test/','/test2/',$str);