Match Start and End of Line
^abcand\Aabcmatchabcat the start of whole stringabc$andabc\Zmatchabcat the start of whole string^abcmatchabcat the start of each lineabc$matchabcat the start of each line
cs
_ = new Regex(@"^abcefg$", RegexOptions.Multiline);1
^always matches after\n, so\n^is redundant$always matches before\n, so$\nis redundant\A\Zmatches empty string and empty string with a single new line\A\zmatches only empty string
TIP
Always use \A and \Z instead of ^ and $ when to match start/end of a whole string
Mode modifier
Use (?m)/(?-m) to enable/disable multiline mode in regex literal
Conclusion
\Aand\Zalways match the start and end of a subject string(?-m)^abcand(?-m)$abcare equivalent to\Aabcand\Zabc\zmatches the end of the subject stringabc\Zmatches before line break whileabc\zwon't match if line break exists afterabc