$str = "<span>lin</span> == <span>3615</span>";
$pattern = "/<span>(.*)<\/span>/";
$str = preg_replace($pattern, "<span class='fuck'>$1</span>", $str);
print_r($str);
$pattern 中没有问号
结果为:<span class='fuck'>lin</span> == <span>3615</span>
$str = "<span>lin</span> == <span>3615</span>";
$pattern = "/<span>(.*?)<\/span>/";
$str = preg_replace($pattern, "<span class='fuck'>$1</span>", $str);
print_r($str);
$pattern 中有问号(相当于防止贪婪匹配)
结果为:<span class='fuck'>lin</span> == <span class='fuck'>3615</span>
$str = "<span>lin</span> == <span>3615</span>";
$pattern = "/<span>(.*)<\/span>/U";
$str = preg_replace($pattern, "<span class='fuck'>$1</span>", $str);
print_r($str);
$pattern 中无问号( U 防止贪婪匹配)
结果为:<span class='fuck'>lin</span> == <span class='fuck'>3615</span>
$str = "<span>lin</span> == <span>3615</span>";
$pattern = "/<span>(.*?)<\/span>/U";
$str = preg_replace($pattern, "<span class='fuck'>$1</span>", $str);
print_r($str);
$pattern 中有问号( U 防止贪婪匹配),相当于失去了U的意义
<span class='fuck'>lin</span> == <span>3615</span>