Merge pull request #20495 from github/tausbn/python-fix-unmatchable-dollar-in-lookahead

Python: Fix false positive for unmatchable dollar/caret
This commit is contained in:
Taus
2025-09-25 15:27:32 +02:00
committed by GitHub
5 changed files with 66 additions and 29 deletions

View File

@@ -150,4 +150,12 @@ re.compile(r"[\U00010000-\U0010FFFF]")
re.compile(r"[\u0000-\uFFFF]")
#Allow unicode names
re.compile(r"[\N{degree sign}\N{EM DASH}]")
re.compile(r"[\N{degree sign}\N{EM DASH}]")
#Lookahead assertions. None of these are unmatchable dollars:
re.compile(r"^(?=a$)[ab]")
re.compile(r"^(?!a$)[ab]")
#Lookbehind assertions. None of these are unmatchable carets:
re.compile(r"(?<=^a)a")
re.compile(r"(?<!^a)a")