Regex to separate Numeric from Alpha

python, regex

Solution

>>> re.findall('(\d+|[a-zA-Z]+)', '12fgsdfg234jhfq35rjg')
['12', 'fgsdfg', '234', 'jhfq', '35', 'rjg']

Problem

I have a bunch of strings: ``` "10people" "5cars" .. ``` How would I split this to? ``` ['10','people'] ['5','cars'] ``` It can be any amount of numbers and text. I'm thinking about writing some sort of regex - however I'm sure there's an easy way to do it in Python.

Original source