import re
text = 'this is a text'
try:
found = re.search('is(.+?)text', text).group(1)
except AttributeError:
# AAA, ZZZ not found in the original string
found = '0 wtitle' # apply your error handling
found
=> a
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter