\S matches any character that isn't a white space character. - Java Regular Expressions

Java examples for Regular Expressions:Pattern

Description

\S matches any character that isn't a white space character.

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(".\\S.");
    Matcher matcher = pattern.matcher(" 2 ");
    if (matcher.matches())
      System.out.println("Match.");
    else/*w w w . j av  a  2  s .c  o  m*/
      System.out.println("Does not match.");
  }

}

Related Tutorials