Java examples for Regular Expressions:Pattern
Use regex patterns to match a string literal exactly
import java.util.regex.Matcher; import java.util.regex.Pattern; public class Main { public static void main(String[] args) { Pattern pattern = Pattern.compile("abc"); Matcher matcher = pattern.matcher("abc"); if (matcher.matches()) System.out.println("Match."); else/* w w w . j a v a 2s. c om*/ System.out.println("Does not match."); } }