python 正则表达式 锚字符
^ 行首匹配,和[]里的不是一个意思
$ 行尾匹配
\A 匹配字符串开始,他和^区别是:\A他只匹配整个字符串的开头,即使在re.M模式下,他也不会匹配它行的行首
\Z 匹配字符串结束,他和$区别是:\Z他只匹配整个字符串的结束,即使在re.M模式下,他也不会匹配它行的行尾
\b 匹配一个单词的边界(单词的最后一个字符串,单词后面有空格也可以匹配),也就是这单词和空格之间的位置
\B 匹配非单词的边界,
import re
print(re.findall("^sunck","sunck is a good man sunck\nsunck is a nice man",re.M))
print(re.findall("\Asunck","sunck is a good man\nsunck is a nice man",re.M))
print(re.findall("man$","sunck is a good man\nsunck is a nice man",re.M))
print(re.findall("man\Z","sunck is a good man\nsunck is a nice man",re.M))
print(re.search(r"er\b","never"))
print(re.search(r"er\b","nerve"))
print(re.search("er\B","never"))
print(re.search("er\B","nerve"))
热门推荐
1 狗狗下楼训练
3 狗狗训练头盔
6 狗狗训练机构
7 训练狗狗步骤
9 狗狗能训练
10 狗狗基本动作训练方法
11 怎么训练狗狗叼饭盆
12 狗狗一岁了还能训练吗
13 训练狗狗的
14 宁波狗狗训练
15 训练狗狗拉屎
16 教狗狗训练
17 狗狗要怎么训练上厕所
18 狗狗靠的训练