So, I have this string: a='test32' I want to separate this string so I get the text and the number in two separate variables, in python .
Asked
Active
Viewed 100 times
1 Answers
1
import re
r = re.compile("([a-zA-Z]+)([0-9]+)")
>>> m=r.match('test32')
>>> m.group(1)
'test'
>>> m.group(2)
'32'
>>>

Eliethesaiyan
- 2,327
- 1
- 22
- 35