Java examples for Regular Expressions:Pattern
\S matches any character that isn't a white space character.
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."); } }