Regular Expressions: difference between ^ and \A

regex

Solution

Yes. `\A` will match at the very beginning of your value. `^` will match the beginning of the value, but will also match immediately after newlines in multiline mode (`//m`).

The `\Z` is similar, but with the end of the value. However, it will also match before a newline at the end of the value. If you don't want this behaviour, use `\z`, which matches only at the end of the value.

Useful reference: perlre manpage

Problem

Is the only difference between `^` and `\A` the fact that `\A` can never match after a line break? (even in multi-line mode) ``` The PCRE man page says: ^ assert start of string (or line, in multiline mode) ... \A matches at the start of the subject ``` Thanks!

Original source

Related problems