Home > Web Front-end > JS Tutorial > 去除html代码里面的script正则方法_javascript技巧

去除html代码里面的script正则方法_javascript技巧

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-05-23 13:15:53
Original
1564 people have browsed it

去除html代码里面的script正则方法

/**
 * 去除html代码里面的脚本字符(<script ...>...</script>和<script ... />
 * @author ob
 *
 */
public class Regex {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		//注意,这里有大小写
		String s = "<script type='text/javascript'>aaaa</SCript>bbbbbbbbb<SCRIPT type='text/javascript' />ccccc<SCRIPT type='text/javascript' >mm</SCRIPT>";
		s = s.replaceAll("(&#63;i)(<SCRIPT)[\\s\\S]*&#63;((</SCRIPT>)|(/>))", "");//忽略大小写的正则
		System.out.println(s);
	}

}
Copy after login

运行结果:bbbbbbbbbccccc

以上这篇去除html代码里面的script正则方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持脚本之家。

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