Regular expression, remove onclick solution-php Tutorial

Source: Internet
Author: User
Trim & quot; border & quot; 0 & quot; onclick & quot; if (this. pa regular, remove onclick
$ Str = 'screen. width-461) window. open (\ 'http: // response); "> ';

I want to remove the onclick in the above string. the regular expression I write is as follows:
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 );
It seems that my results cannot be achieved. how can I remove regular expressions?

------ Solution --------------------
"/Onclick = ('| \")? (. *) \ 1/sU"

That's all.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.