String str ="${time}";
String req="\\$\\{([a-z]{4})\\}";
Pattern pattern=Pattern.compile(req);
Matcher m=pattern.matcher(str);
String c = m.group(1)
boolean s=m.find();
System.out.println(c);
怎样拿到Matcher m=pattern.matcher(str);里分组的值 也就是字符串里time的值 String c = m.group(1)拿不到 报java.lang.IllegalStateException: No match found错
String req="\\$\\{([a-z]{4})\\}";
Pattern pattern=Pattern.compile(req);
Matcher m=pattern.matcher(str);
String c = m.group(1)
boolean s=m.find();
System.out.println(c);
怎样拿到Matcher m=pattern.matcher(str);里分组的值 也就是字符串里time的值 String c = m.group(1)拿不到 报java.lang.IllegalStateException: No match found错
解决方案 »
- 一直看不出来这个异常出在哪里...基础没学好..苦逼啊..
- tomcat数据库连接池问题
- JAVA 注释问题
- Struts datasource jar包 下载地址 谁知道
- 请问用hibernate从mssql2000中取中文显示乱码,数据库是用utf8存的??
- [300分]如何写一个监听的Servlet对配置在web.xml中的config.xml进行解析,并把config.xml中的一个Servlet实例化加载到缓存中并在程序
- HibernateSynchronizer使用问题
- Hibernate 回滚时报错 Transaction not successfully started
- Hibernate 插入一条数据后查询出现问题
- Tomcat5的errorPage问题
- Spring中的@Transactional用法疑问
- tomcat 自动设置 重新启动出错 问题
import java.util.regex.Matcher;
import java.util.regex.Pattern;public class Test {
public static void main(String[] args) {
String str ="${time}";
String req="\\$\\{([a-z]{4})\\}";
Pattern pattern=Pattern.compile(req);
Matcher m=pattern.matcher(str);
boolean s=m.find();
if (s) {
String c = m.group(1);
System.out.println(c);
} else {
System.out.println("Not found.");
}
}
}