Python's meaning of ^ is "start of string, or in /m mode after any newline".
This is different to PCRE2's default meaning for ^, which is "start of string, or in /m mode after newlines which are not the last character in the file".
You are using PCRE2 I believe to emulate Python support? You need to set PCRE2_ALT_CIRCUMFLEX to get behaviour matching Python.
Reproduction steps
Switch Regex101 to Python mode, with r"..."gm flags
Use the regex ^$
Use the text "a\<trailing newline>"
Expected Outcome
Python produces one match. Regex101 reports zero matches (same as PCRE2)
Bug Description
Python's meaning of
^
is "start of string, or in /m mode after any newline". This is different to PCRE2's default meaning for^
, which is "start of string, or in /m mode after newlines which are not the last character in the file".You are using PCRE2 I believe to emulate Python support? You need to set PCRE2_ALT_CIRCUMFLEX to get behaviour matching Python.
Reproduction steps
r"..."gm
flags^$
Expected Outcome
Python produces one match. Regex101 reports zero matches (same as PCRE2)
Verification:
Browser
Include browser name and version
OS
Include OS name and version