正则,去掉onclick
$str = 'screen.width-461) window.open(\'http://www.kerehou.com/attachment/photo/mon_1205/1265_5d971336976610640809cc1dfe218.jpg\'); >';
我想去掉上面字符串中的onclick,我写的正则如下:
function clear_onclick($document) {
if (!$document) return $document;
$search = array(
/onclick=('|\|)?(.*)('|\|)/ismue,
);
$replace = array( ,
);
$text = preg_replace($search,$replace,$document);
return $text;
}
echo clear_onclick($str);
貌似达不到我的效果,请教一下如何写正则去掉?
------解决方案--------------------
/onclick=('|\)?(.*)\\1/su
这样就好了吧