Answers for "python how to extract a string from another string"

0

python how to extract a string from another string

>>> s = 'gfgfdAAA1234ZZZuijjk'
>>> start = s.find('AAA') + 3
>>> end = s.find('ZZZ', start)
>>> s[start:end]
'1234'
Posted by: Guest on April-04-2021
0

python how to extract a string from another string

import re

text = 'gfgfdAAA1234ZZZuijjk'

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

# found: 1234
Posted by: Guest on April-04-2021

Code answers related to "python how to extract a string from another string"

Python Answers by Framework

Browse Popular Code Answers by Language