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 训练狗狗憋尿
2 狗狗追踪训练
3 狗狗训练要多少钱
5 深圳狗狗训练
6 训练狗狗唤回
7 狗狗叫怎么训练
8 狗狗训练班
10 狗狗社会化训练
11 狗狗叫回训练
12 广州狗狗训练学校
13 狗狗训练躺下
14 狗狗随行训练
15 训练狗狗巡回
16 狗狗要怎么训练
17 狗狗喂食训练
18 训练狗狗躺下