Regular Expressions Anchor Characters: Caret (^) Comparison start of line anchor and start of string anchor


While many people think that ^ means the start of a string, it actually means start of a line. For an actual start of string anchor use, \A.

The string hello\nworld (or more clearly)


Would be matched by the regular expressions ^h, ^w and \Ah but not by \Aw