两者有什么区别
\A Match at only beginning of string
\Z Match at only end of string (or before newline at the end)
^ Match the beginning of the line
$ Match the end of the line (or before newline at the end)
最佳答案
来自 perl 文档(我在标准正则表达式语法中看不到它们):
The "\A" and "\Z" are just like "^" and "$", except that they won't match multiple times when the "/m" modifier is used, while "^" and "$" will match at every internal line boundary.
如果这仅与 Perl(或使用 PCRE、Perl 兼容正则表达式的语言或库)相关,则您应该添加 perl 标记。
关于正则表达式 - 边界字符(^ 和 $)与转义字符(\A 和\Z),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7483549/