Python's re
module documentation says:
^
: (Caret.) Matches the start of the string, and in MULTILINE mode also matches immediately after each newline.
\A
: Matches only at the start of the string.
Is there any difference when using them?
Both of these match:
re.search('^abc', 'abc')
re.search('\Aabc', 'abc')
This also matches:
re.search('^abc', 'firstline\nabc', re.M)
This does not:
re.search('\Aabc', 'firstline\nabc', re.M)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With