Reading Time: 1 minutes
Obtain numbers from an alphanumeric string in Python
Obtain numbers from an alphanumeric string. Write a Regular Expression in Python to obtain a list of numbers from a string containing alphanumeric characters.
Obtain numbers from an alphanumeric string
import re sourceString = '1a2b3c4de5f6' print( re.split('[a-zA-Z]+', sourceString) ) # ['1', '2', '3', '4', '5', '6']
To learn more about Regular Expressions in Python, click here.