`
haohappy2
  • 浏览: 325911 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

Replace of HTML tag

    博客分类:
  • PHP
 
阅读更多
$str=preg_replace("/\s+/", " ", $str); //过滤多余回车
$str=preg_replace("/<[ ]+/si","<",$str); //过滤<__("<"号后面带空格)
  
$str=preg_replace("/<\!--.*?-->/si","",$str); //注释
$str=preg_replace("/<(\!.*?)>/si","",$str); //过滤DOCTYPE
$str=preg_replace("/<(\/?html.*?)>/si","",$str); //过滤html标签
$str=preg_replace("/<(\/?head.*?)>/si","",$str); //过滤head标签
$str=preg_replace("/<(\/?meta.*?)>/si","",$str); //过滤meta标签
$str=preg_replace("/<(\/?body.*?)>/si","",$str); //过滤body标签
$str=preg_replace("/<(\/?link.*?)>/si","",$str); //过滤link标签
$str=preg_replace("/<(\/?form.*?)>/si","",$str); //过滤form标签
$str=preg_replace("/cookie/si","COOKIE",$str); //过滤COOKIE标签
  
$str=preg_replace("/<(applet.*?)>(.*?)<(\/applet.*?)>/si","",$str); //过滤applet标签
$str=preg_replace("/<(\/?applet.*?)>/si","",$str); //过滤applet标签
  
$str=preg_replace("/<(style.*?)>(.*?)<(\/style.*?)>/si","",$str); //过滤style标签
$str=preg_replace("/<(\/?style.*?)>/si","",$str); //过滤style标签
  
$str=preg_replace("/<(title.*?)>(.*?)<(\/title.*?)>/si","",$str); //过滤title标签
$str=preg_replace("/<(\/?title.*?)>/si","",$str); //过滤title标签
  
$str=preg_replace("/<(object.*?)>(.*?)<(\/object.*?)>/si","",$str); //过滤object标签
$str=preg_replace("/<(\/?objec.*?)>/si","",$str); //过滤object标签
  
$str=preg_replace("/<(noframes.*?)>(.*?)<(\/noframes.*?)>/si","",$str); //过滤noframes标签
$str=preg_replace("/<(\/?noframes.*?)>/si","",$str); //过滤noframes标签
  
$str=preg_replace("/<(i?frame.*?)>(.*?)<(\/i?frame.*?)>/si","",$str); //过滤frame标签
$str=preg_replace("/<(\/?i?frame.*?)>/si","",$str); //过滤frame标签
  
$str=preg_replace("/<(script.*?)>(.*?)<(\/script.*?)>/si","",$str); //过滤script标签
$str=preg_replace("/<(\/?script.*?)>/si","",$str); //过滤script标签
$str=preg_replace("/javascript/si","Javascript",$str); //过滤script标签
$str=preg_replace("/vbscript/si","Vbscript",$str); //过滤script标签
$str=preg_replace("/on([a-z]+)\s*=/si","On\\1=",$str); //过滤script标签
$str=preg_replace("/&#/si","&#",$str); //过滤script标签,如javAsCript:alert(

 

分享到:
评论

相关推荐

    asp.net去除html标记

    tag = tag.Substring(0, tag.IndexOf('&gt;')).Replace(", ""); else tag = tag.Replace(", "").Replace("&gt;", ""); content += "&lt;/" + tag + "&gt;"; } return content.Substring(0, Math.Min(length, content....

    JSP生成静态HTML页面的几种方法

    String fileame = String.valueOf(calendar.getTimeInMillis()) + ".html"; fileame = request.getRealPath("/") + fileame; FileOutputStream fileoutputstream = new FileOutputStream(fileame); byte tag_...

    Java邮件开发Fundamentals of the JavaMail API

    Fundamentals of the JavaMail API Presented by developerWorks, your source for great tutorials ibm.com/developerWorks Table of Contents If you're viewing this document online, you can click ...

    simple-tags

    * The Simple Tags auto completion replace default WordPress Tags input. * Restore administration options. * Better management of Simple Tags with WP_Scripts and WP_Styles * Add an option for auto ...

    正则表达式替换html元素属性的方法

    function replace_html_tag_attr(src_str, tag, attr, val) { if (typeof src_str === 'undefined' || typeof tag === 'undefined' || typeof attr === 'undefined' || typeof val === 'undefined') { return ''; ...

    JavaScript APIs HTML5

    HTML5 has introduced numerous powerful features and functionalities to the web development world, significantly enhancing the capabilities of web applications. This document provides an overview of ...

    另存為按鈕.html

    **描述:“Select any portion of the following blue text, such as "My favorite Web site". Click the button to turn the selected text into a link. The text will be changed to the URL that you specify”*...

    Velocity Suite 1.2.3

    [Version 1.0.4 fixed lack of vtl tag hints and vtl code coloring missing in previous versions, to invoke code coloring you must have \"#* velocity document *#\" at the beginning of your .vm or .html ...

    Prototype Cheat Sheet

    - **`replace(element[, html])`**: Replaces an element with HTML content. - **`scrollTo(element)`**: Scrolls the document so that an element is visible. - **`select(element, selector)`**: Selects ...

    Beautiful Soup documentation.pdf

    and they lived at the bottom of a well. """ soup = BeautifulSoup(html_doc, 'html.parser') ``` - **XML解析**: - 使用`xml`作为解析器,适用于XML文档。 - 示例代码: ```python xml_doc = """ ...

    httpd2.2.12.tar

    hunting to replace binary third party modules that were now incompatible. This also left module authors searching through the API change histories to determine the exact cause for the MMN change and ...

    浮点vfdsfJAVA实现链表,双向链表.txtJAVA实现链表,双向链表.txt

    描述&gt;=20个字符,不支持HTML标签。 详细的资源描述有机会获得我们的推荐,更有利于他人下载,赚取更多积分。 &lt;li&gt;&lt;input id="cb_agree" name="cb_agree" type="checkbox" value="" /&gt;同意...

    利用 Oracle 和 PHP 管理分布式跟踪文件

    create or replace library systemcalls is ‘/lib/libc.so‘; / grant necessary database privileges to tfmadmin tfmAdmin_privs_and_syns.sql grant necessary java privileges to tfmadmin tfmAdmin_java_...

    JS实现关键词高亮显示正则匹配

    text = text.replace(re, `&lt;${tag} class="highlight"&gt;$&${tag}&gt;`); } } return text; } ``` 2. **`highlight` 函数**: 这个函数则尝试匹配整个关键词,而不是单个字符。它同样接受三个参数:`text`、`...

    Eclipse图标意义

    * adornment that marks a stack frame that may be out of synch with the target VM as a result of an unsuccessful hot code replace:栈帧修饰,表示栈帧可能与目标VM不同步。 Eclipse图标意义是Eclipse中最...

    jQuery完全实例.rar

    For example, to create a span use $("&lt;span/&gt;") or $("&lt;span&gt;&lt;/span&gt;") instead of without the closing slash/tag. 返回值 jQuery 参数 html (String) : 用于动态创建DOM元素的HTML标记字符串 示例 动态创建...

    PHP基础知识总结

    此外,在使用简短方式时,需要注意服务器配置(`short_open_tag` 配置项)是否允许。 #### 二、PHP 的注释 PHP 支持三种类型的注释: 1. **单行注释**:使用 `//` 开始的注释。 ```php // 单行注释示例 ``` 2...

    BUS Hound

    The following table describes the units of the time format. &lt;br&gt;Name Units us Microseconds ms Milliseconds sc Seconds mn Minutes hr Hours dy Days &lt;br&gt; Cmd.Phase.Ofs(rep) ...

    收集的Javascript定义信息

    在`parseAvatarts()`函数中,通过`indexOf`方法检查字符串是否包含特定子串,以及`replace`方法替换字符串中的部分字符,展现了JavaScript中字符串处理的基本技巧。同时,通过条件语句如`if`和`else if`实现逻辑判断...

Global site tag (gtag.js) - Google Analytics