为何下面的字符串无法匹配正则?String regex = "<(\\S*?)[^>]*>.*?</\1>|<.*? />";
String str = "<p>abcd</p>";
解决方案 »
- org.springframework.jdbc.BadSqlGrammarException:
- 针对没有工作或者想找点java网站做的人士看
- 抓取数据后如何分析数据提取想要的数据写库
- 实际的开发中一般都用spring的aop来做什么工作呢?
- 大家说下这两个域名哪个好,我想做一个JAVA教学的网址。www.axjava.com,www.javacool.org
- struts2 action的方法和返回值类型问题
- 关于异常:[Microsoft][SQLServer 2000 Driver for JDBC]Error establishing socket?
- 在eclipse中如何安装jbpm插件
- tomcat突然不正常
- 关于spring整合hibernate的问题
- 【大侠,看过来!!!】java处理数据和oracle处理数据的比较(没人知道吗?)
- 内存溢出
package com.zf.test;public class Test05 { public static void main(String[] args) {
String regex = "<(\\S.*?).*?((/>)|(</\\1>))";
String str = "<p>abcd</p>";
System.out.println(str.matches(regex));
str = "<br/>";
System.out.println(str.matches(regex));
str = "<span>fdfsdfsd</span>";
System.out.println(str.matches(regex));
str = "<span>fdfsdfsd</div>";
System.out.println(str.matches(regex));
}}
true
true
true
false