Php uses regular expressions to filter various tags, spaces, and line breaks.

Source: Internet
Author: User

Collect php code that uses regular expressions to filter various labels, spaces, and line breaks:

$ Str = preg_replace ("/\ s +/", "", $ str); // filter excess carriage returns $ str = preg_replace ("/<[] +/si ", "<", $ str); // filter <__( "<" followed by a space) $ str = preg_replace ("/<\! -.*? ->/Si "," ", $ str); // comment $ str = preg_replace ("/<(\!. *?)> /Si "," ", $ str); // filter DOCTYPE $ str = preg_replace ("/<(\/? Html. *?)> /Si "," ", $ str); // filter html tags $ str = preg_replace ("/<(\/? Head. *?)> /Si "," ", $ str); // Filter head tags $ str = preg_replace ("/<(\/? Meta. *?)> /Si "," ", $ str); // filter meta tags $ str = preg_replace ("/<(\/? Body. *?)> /Si "," ", $ str); // filter the body Tag $ str = preg_replace ("/<(\/? Link. *?)> /Si "," ", $ str); // filter link tags $ str = preg_replace ("/<(\/? Form. *?)> /Si "," ", $ str); // Filter form tags $ str = preg_replace ("/cookie/si "," COOKIE ", $ str ); // filter COOKIE tags $ str = preg_replace ("/<(applet. *?)> (.*?) <(\/Applet. *?)> /Si "," ", $ str); // filter the applet tag $ str = preg_replace ("/<(\/? Applet. *?)> /Si "," ", $ str); // filter the applet tag $ str = preg_replace ("/<(style. *?)> (.*?) <(\/Style. *?)> /Si "," ", $ str); // filter the style tag $ str = preg_replace ("/<(\/? Style. *?)> /Si "," ", $ str); // filter the style tag $ str = preg_replace ("/<(title. *?)> (.*?) <(\/Title. *?)> /Si "," ", $ str); // filter the title Tag $ str = preg_replace ("/<(\/? Title. *?)> /Si "," ", $ str); // filter the title Tag $ str = preg_replace ("/<(object. *?)> (.*?) <(\/Object. *?)> /Si "," ", $ str); // filter the object tag $ str = preg_replace ("/<(\/? Objec. *?)> /Si "," ", $ str); // filter the object tag $ str = preg_replace ("/<(noframes. *?)> (.*?) <(\/Noframes. *?)> /Si "," ", $ str); // filter noframes tags $ str = preg_replace ("/<(\/? Noframes. *?)> /Si "," ", $ str); // filter noframes tags $ str = preg_replace ("/<(I? Frame. *?)> (.*?) <(\/I? Frame. *?)> /Si "," ", $ str); // filter the frame tag $ str = preg_replace ("/<(\/? I? Frame. *?)> /Si "," ", $ str); // filter the frame tag $ str = preg_replace ("/<(script. *?)> (.*?) <(\/Script. *?)> /Si "," ", $ str); // filter the script tag $ str = preg_replace ("/<(\/? Script. *?)> /Si "," ", $ str); // filter the script tag $ str = preg_replace ("/javascript/si "," Javascript ", $ str ); // filter the script tag $ str = preg_replace ("/vbscript/si", "Vbscript", $ str ); // filter the script tag $ str = preg_replace ("/on ([a-z] +) \ s * =/si", "On \ 1 = ", $ str); // filter script tags $ str = preg_replace ("// & #/si", "& #", $ str); // filter script tags
Articles you may be interested in
  • PHP compresses html webpage code (clear spaces, line breaks, tabs, comment tags)
  • Php converts multiple consecutive spaces in a string into one.
  • Css controls code for force-breaking and non-wrapping in English and Chinese
  • Common PHP anti-injection vulnerability filtering function code
  • Php uses array_flip to implement array key-value exchange to remove array duplicate values
  • Javascript shares the content with the code Summary of the websites on major social networking platforms
  • How does php clear html format, remove spaces in text, and intercept text?
  • Prohibit web page right-click, copy, save as, View Source file and other functions to implement web page source code protection

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.