End of line anchor $ match even there is extra trailing \\n in matched string, so we use \\Z instead of $
$
\\n
\\Z
For example
Most often it's used when also enabling multi-line matches. Since \A only matches at the beginning of the ENTIRE text, as opposed to just a line beginning, in regexes that can match across lines the functionality of ^ and \A are different.
\A
^