Ads by ProfitSence

Extract the substring between two markers

Last Updated on Wednesday 5th Oct 2022

Python Extract SubString

Regular expressions use the backslash character ('\') to indicate special forms or to allow special characters to be used without invoking their special meaning.A regular expression (or RE) specifies a set of strings that matches it.

  • re — Regular expression operations.
					import re
m ='(?<=abc)def', 'abcdef')

print( # def


python string extract

					import re

text = 'gfgfdAAA1234ZZZuijjk'

    found ='AAA(.+?)ZZZ', text).group(1)
except AttributeError:
    # AAA, ZZZ not found in the original string
    found = '' # apply your error handling

print(found) # 1234


Python Regex Extract SubString

					import re


# 1234