I have following code
stringA = "xxxxxxFoundAaaaaaaaaaaaaaaFoundBxxxxxxx"
stringB = "FoundA"
stringC = "FoundB"
How do I do a regular expression in python in order to return aaaaaaaaaaaaaa
?
>>>
>>> stringA = "xxxxxxFoundAaaaaaaaaaaaaaaFoundBxxxxxxx"
>>> stringB = "FoundA"
>>> stringC = "FoundB"
>>>
>>> import re
>>> re.search(re.escape(stringB)+"(.*?)"+re.escape(stringC),stringA).group(1)
'aaaaaaaaaaaaaa'
>>>
re.search(re.escape(stringB) + "(.*?)" + re.escape(stringC), stringA).group(1)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With