Lookahead in Group
alvarofpp opened this issue · comments
Lookahead assertion
(?=...)
from mre import Regex, Group
# Example of how it can work 1
print(Regex("Isaac", Group(" Asimov", lookahead=True)))
# Output: Isaac(?= Asimov)
# Regex without lookahead: Isaac( Asimov)
Negative lookahead assertion
(?!...)
from mre import Regex, Group
# Example of how it can work 1
print(Regex("Isaac", Group(" Asimov", lookahead=False)))
# Output: Isaac(?! Asimov)
# Regex without lookahead: Isaac( Asimov)
Note: the default value of the lookahead
parameter is None
.
Hi,
I'd like to take on this one :-)
I would say there's something wrong here in mixing Group with lookahead (and lookbehind for that mather). They are different things. Looking around in a regex is a non-capturing operation and has a different semantic than grouping although in uses the same symbol to start. I would recommend having a separated class for that.