I am trying to match all instances of the pattern in the string using Python. However, when the patterns overlap I get only the longest one, while I need both:
import re
st = '''GYMGMTPRLGLESLLEStopAS'''
w = re.findall("M\w*?(?=Stop)",st)
print w
Output:
1. MGMTPRLGLESLLE
Desired output:
1. MGMTPRLGLESLLE
2. MTPRLGLESLLE
(?=(M\w*?)Stop) Then the overlapp data is in capture 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