有什么区别,
\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)
答案 0 :(得分:4)
从perl文档(我在标准正则表达式语法中看不到它们):
“\ A”和“\ Z”就像“^”和“$”,只是在使用“/ m”修饰符时它们不会多次匹配,而“^”和“$” “将在每个内线边界匹配。
如果只与Perl(或那些使用PCRE,Perl兼容的正则表达式的语言或库)相关,那么你应该添加一个perl标签。
答案 1 :(得分:1)
\A
始终匹配字符串的开头,并且在换行后从不匹配,而许多方言也可以使^
与行的开头匹配。
http://www.regular-expressions.info/reference.html(寻找'Anchors')。