Note Without the m flag, ^ matches only the very beginning of the entire string. With the m flag, it matches the start of each line (after every newline character).
Note A word boundary exists at three positions: before the first \w character, after the last \w character, and between a \w and \W character. It does NOT match any characters itself -- it matches a position.
word boundary detailwhole wordstandalone wordboundary position
\A Absolute Start of String (Python)
syntax
\A matches the very start of the string (ignores multiline)
\A always means absolute start, even with re.MULTILINE
Note \A is not available in JavaScript. It is equivalent to ^ when multiline mode is off, but unlike ^, it never changes behavior with the m flag. Use \A in Python when you always mean the beginning of the entire string.
\Z matches only the absolute end, regardless of flags
Note In Python, \Z matches the absolute end (after the last character). Note: \z (lowercase) is used in some other flavors (Ruby, PCRE) for the same purpose, while Python's \Z (uppercase) does not match before a trailing newline. Not available in JavaScript.
absolute end\Z anchorpython endignore multiline end
["line1", "line2", "line3"] (each line start matched)
Note Without the m flag, only 'line1' would match ^\w+. A common mistake is forgetting the m flag when processing multi-line text like log files or configuration files. In Python, re.MULTILINE or re.M is the flag; in JS, use /m.