In regular expressions, there are several ways to specify the beginning of a line:
^
This unshielded circumflex, not immediately after the unshielded open square bracket [ , finds the beginning of the text (string).
However, in Ruby ^ finds only the beginning of the line (line). To find the beginning of the entire text, you must use
\A
This anchor can also be used in other regular expression languages / libraries: in .NET, Python (re, regex), PHP (PCRE), Java, Swift / Objective-C (ICU).
By the way, in text editors such as Notepad ++, ^ also used to find the beginning of a line (line), and not the entire text.
Do not confuse the anchor ^ with other functions of this symbol. Cm.