Answers for "how to check if string contains only digits"

6

check if string contains numbers

str.matches(".*\\d.*");
Posted by: Guest on November-01-2020
0

check if string has digits python

string = 'this string has digits 12345'
if any(char.isdigit() for char in string):
  #digits found
  print('"{}" has digits!'.format(string))
else:
  #digits NOT found
  print('"{}" does NOT have digits!'.format(string))
Posted by: Guest on April-18-2022

Code answers related to "how to check if string contains only digits"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language