Python 3.4 introduced the new regex method re.fullmatch(pattern, string, flags=0)
.
Has anyone back-ported this new method to older Python versions?
Python 3.4 introduced the new regex method re.fullmatch(pattern, string, flags=0)
.
Has anyone back-ported this new method to older Python versions?
Here it is my backporting, which has at least one problem (thanks tim-pietzcker) but does not require recompiling regexes:
And here are some test-cases proving the above emulation-function.
To make sure that the entire string matches, you need to use the
\Z
end-of-string anchor:The
\A
anchor is not necessary sincere.match()
already anchors the match to the start of the string.