import java.util.regex.*;public class bbb {
static String xx = "123123";
public static void main(String[] args) {
Pattern p = Pattern.compile("/123/");
Matcher m = p.matcher(xx);
boolean b = m.find();
System.out.print(b);
}
}为什么我总返回false呢?谢谢大家先。
static String xx = "123123";
public static void main(String[] args) {
Pattern p = Pattern.compile("/123/");
Matcher m = p.matcher(xx);
boolean b = m.find();
System.out.print(b);
}
}为什么我总返回false呢?谢谢大家先。
static String xx = "123123";
public static void main(String[] args) {
Pattern p = Pattern.compile("123"); //不需要反斜杠,因为""不是要匹配的字符.
Matcher m = p.matcher(xx);
boolean b = m.find();
System.out.print(b);
}
}
System.out.println("aaab")
结果是aabb
而:
System.out.println("/"aaab/"")
结果是"aabb"
Returns:
true if, and only if, a subsequence of the input sequence matches this matcher's pattern