Java String match single number in String
public class Main { public static void main(String[] args) { String str = ""; // test to see if any numbers are present str = "Java 9"; boolean result = str.matches("Java [0-9]"); System.out.println(result); }/*from w w w . jav a 2s . c o m*/ }