正则表达式—数量词
public class Demo4_Regex {
public static void main(String[] args) {
}
public static void demo6() {
String regex = "[abc]{5,15}";
System.out.println("abcab".matches(regex));
System.out.println("ab".matches(regex));
System.out.println("aabbccccaaaabb".matches(regex));
System.out.println("aabbccccaaaabbba".matches(regex));
}
public static void demo5() {
String regex = "[abc]{2,}";
System.out.println("abcab".matches(regex));
System.out.println("ab".matches(regex));
System.out.println("a".matches(regex));
}
public static void demo4() {
String regex = "[abc]{2}";
System.out.println("abc".matches(regex));
System.out.println("ab".matches(regex));
System.out.println("a".matches(regex));
}
public static void demo3() {
String regex = "[abc]+";
System.out.println("a".matches(regex));
System.out.println("abc".matches(regex));
System.out.println("".matches(regex));
}
public static void demo2() {
String regex = "[abc]*";
System.out.println("a".matches(regex));
System.out.println("abc".matches(regex));
System.out.println("".matches(regex));
System.out.println("d".matches(regex));
}
public static void demo1() {
String regex = "[abc]?";
System.out.println("a".matches(regex));
System.out.println("b".matches(regex));
System.out.println("c".matches(regex));
System.out.println("d".matches(regex));
System.out.println("".matches(regex));
}
}