Python 的 re
module说的是:
'^'
(Caret.) Matches the start of the string, and in MULTILINE mode also matches immediately after each newline.
我想使用 MULTILINE,但我想要求在字符串的开头(而不仅仅是行的开头)进行匹配。有办法做到这一点吗?
最佳答案
只需使用明确匹配字符串开头的 \A
anchor 即可。
\A
Matches only at the start of the string.
关于python - 在 Python MULTILINE 模式下仅匹配字符串的开头,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33312247/