Thank you in advance for reading.
I have a string:
A = "a levels"
I want to match all of the following possible variations of A level:
Pattern = r"a level|a levels"
(The form of this pattern is set, I cannot change it.) Following the search, I desire to get:
["a level","a levels"]
I use findall as follows:
B = re.findall(Pattern,A)
and get:
B = "a level"
re.findall only matches the first term and ignores the second overlapping term.
Per: Python regex find all overlapping matches? I tried using:
B = re.findall(Pattern,A,overlapped = True)
and get the following error:
TypeError: findall() got an unexpected keyword argument 'overlapped'
Obviously overlapped
doesn't exist as a keyword argument any more...
I then looked at this question: Python regex find all overlapping matches? and tried:
C = re.finditer(Pattern,A)
results = match.group()
results = "a level"
So no better.
How can I get the output I desire?
Relevant qu: How to find overlapping matches with a regexp?