how to check a string contains only numeric values code example Example: check if string contains numbers str.matches(".*\\d.*");