<?php
$str=<<<start
<a href="http://" target="_blank" stat="123fdsfdsfds">aaa</a>
start;
$pattern="((stat\=\".+?)\")";
$replace="";
$result=preg_replace($pattern,$replace,$str);
echo $result;
?>
上面應該屬於非貪婪匹配的方法吧,個人也是學習php的時候,在網上看到的說法:
運行代碼得到的結果是:
<a href="http://" target="_blank" >aaa</a>
大家可以試下!
參考網站:http://cn.php.net/preg_replace/
學習php的朋友,一起討論哈。