Note Matches position at end of string. With the m flag, $ matches the end of each line. In Python, re.match only checks the start -- use re.search with $ to check the end.
Note Without the m flag, $ matches the very end of the string (or before a trailing newline in Python). With m, it matches the end of each line.
Frequently asked questions
How does Regular Expressions handle anchor end?
Regular Expressions covers this with 2 copy-ready snippets on this page. The "$ End of String" snippet in Regular Expressions uses `pattern$`.
Which pattern does the Regular Expressions example use?
The "$ End of String" snippet uses `pattern$`, from the Basic Patterns section of the Regular Expressions cheat sheet.
What other Regular Expressions snippets are shown for "anchor end"?
Besides "$ End of String", this page also shows "$ End Anchor".
Is there anything to watch out for?
Yes. For "$ End of String": Matches position at end of string. With the m flag, $ matches the end of each line. In Python, re.match only checks the start -- use re.search with $ to check the end.