Java regular expression or rule matching

or rules, which can match multiple rules at the same time.

Two regular rules connected by | means that one of them can be satisfied. For example, Java|PHP|C means that it can match Java or PHP or C.

        String regexh = "Java|PHP|C";
        System.out.println("Java".matches(regexh));// true
        System.out.println("Java8".matches(regexh));// false
        System.out.println("PHP".matches(regexh));// true
        System.out.println("C".matches(regexh));// true
        System.out.println("C++".matches(regexh));// false

Guess you like

Origin blog.csdn.net/weixin_44021334/article/details/134220641