Limit white space characters to actual spaces, just use a space in the regex. - Java Regular Expressions

Java examples for Regular Expressions:Pattern

Description

Limit white space characters to actual spaces, just use a space in the regex.

Demo Code

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.");
  }

}

Related Tutorials