Java examples for Regular Expressions:Pattern
Limit white space characters to actual spaces, just use a space in the regex.
import java.util.regex.Matcher; import java.util.regex.Pattern; public class Main { public static void main(String[] args) { Pattern pattern = Pattern.compile("... ..."); Matcher matcher = pattern.matcher("asd asd"); if (matcher.matches()) System.out.println("Match."); else//w ww . ja v a 2 s . c o m System.out.println("Does not match."); } }