python get words between two words

20

# credit to the Stack Overflow user in the source link
import re

text = 'gfgfdAAA1234ZZZuijjk'

m = re.search('AAA(.+?)ZZZ', text)
if m:
    found = m.group(1)

# found: 1234

Comments

Submit
0 Comments