Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

how to separate numbers from a string in python

#can be done through regex library
import re
some_string = '31 Kaiser Friedrich Avenue'
#use the findall() method to find number within the string
#the ‘d+’ would help find digits
num = re.findall(r'd+', some_string)
print(num)
# result would be ['31']
Source by www.askpython.com #
 
PREVIOUS NEXT
Tagged: #separate #numbers #string #python
ADD COMMENT
Topic
Name
6+1 =