-2

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 .

Lodi
  • 13
  • 2

1 Answers1

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