java正则表达式
2010年4月1日
没有评论
例子1
public void testa(){
Pattern p = Pattern.compile(“.*from.*”);
String x = “select cola from ta”;
Matcher m = p.matcher(x);
System.out.println(m.matches());//输出true
}
public void testb(){
Pattern p = Pattern.compile(“.*from.*”,Pattern.CASE_INSENSITIVE);
String x = “select cola FROM ta”; //FROM 大写
Matcher m = p.matcher(x);
System.out.println(m.matches());//输出false
}
public void testC(){
Pattern p = Pattern.compile(“.*from.*”,Pattern.CASE_INSENSITIVE);//忽略大小写
String x = “select cola FROM ta”;
Matcher m = p.matcher(x);
System.out.println(m.matches());//输出true
}
近期评论