正则,去掉onclick解决办法

WBOY
Release: 2016-06-13 13:30:10
Original
807 people have browsed it

正则,去掉onclick
$str = ' 正则,去掉onclick解决办法 ';

我想去掉上面字符串中的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"

这样就好了吧

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template