9"边界匹配

"""边界匹配"""


"""
边界匹配主要用于匹配字符串的边界或字符串中单词的边界。
"""
import re
# ['12']
print(re.findall(r'^d+', '12-3 45-6 78-9')) # ^ 匹配字符串的开头
# ['12', '45', '78']
print(re.findall(r'^d+', '12-3 45-6 78-9', re.M)) # re.M 多行
# ['12']
print(re.findall(r'Ad+', '12-3 45-6 78-9', re.M)) # A 匹配字符串开始
# ['3', '6', '9']
print(re.findall(r'd+$', '12-3 45-6 78-9', re.M)) # $ 匹配字符串的末尾。
原文地址:https://www.cnblogs.com/sruzzg/p/12990208.html