Python 的 re
module documentation说:
^
: (Caret.) Matches the start of the string, and in MULTILINE mode also matches immediately after each newline.
\A
: Matches only at the start of the string.
使用时有什么区别吗?
最佳答案
这两个匹配:
re.search('^abc', 'abc')
re.search('\Aabc', 'abc')
这也匹配:
re.search('^abc', 'firstline\nabc', re.M)
这不是:
re.search('\Aabc', 'firstline\nabc', re.M)
关于python - 正则表达式中的 `\A` 与 `^`(插入符号)之间是否存在差异?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39669147/