find number in string code example
Example 1: python get numbers from string
string = "abc123"
# Method 1
''.join(char for char in string if char.isdigit())
#Method 2
import re
re.sub("[^0-9]", "", string)
Example 2: how to check a number in string
To find whether a given string contains a number,
convert it to a character array and find whether
each character in the array is a digit using the isDigit()
method of the Character class