check if string contains numbers java site:stackoverflow.com code example Example: check if string contains numbers str.matches(".*\\d.*");