📜  java 模式检查 - Java 代码示例

📅  最后修改于: 2022-03-11 14:52:19.735000             🧑  作者: Mango

代码示例1
import java.util.regex.Pattern;

public class PatternMatchesExample {

    public static void main(String[] args) {

        String text    =
            "This is the text to be searched " +
            "for occurrences of the pattern.";

        String pattern = ".*is.*";

        boolean matches = Pattern.matches(pattern, text);

        System.out.println("matches = " + matches);
    }
}