Java examples for Regular Expressions:Match
Check whether the input string matches the regex
//package com.java2s; import java.util.regex.Pattern; public class Main { public static void main(String[] argv) { String input = "java2s.com"; String regex = "java2s.com"; System.out.println(isMatching(input, regex)); }//from w ww . jav a2s.co m public static boolean isMatching(String input, String regex) { return Pattern.compile(regex, Pattern.CANON_EQ).matcher(input) .matches(); } }