Wednesday, 8 February 2017

Regex : PatternMatches




public class PatternMatches {

    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);
        // example 2        System.out.println(" === ===============---============== === ");        boolean b3 = Pattern.matches(".m","am");        System.out.println("matches = " + b3);    }
}

No comments:

Post a Comment