1.特殊字符在正则表达式的应用。
    \d 匹配一个数字字符,等价于[0-9]
    \D 匹配一个非数字字符,等价于[^0-9]
    \s 匹配任意空白字符,包括空格、制表符、换页符等,等价[\f\n\r\t\v]
    \S 匹配非空白字符,等价于[^\f\n\r\t\v]
    \w 匹配包括下划线子内的单词字符,等价于[a-zA-Z0-9]

    2.re 模块
    re.match

    1. import re
    2. print(re.match('hello','hello,world').span()) #在起始位置匹配
    3. print(re.match('hello','hello,world'))#不在起始位置匹配

    图片.png
    re.search

    1. import re
    2. print(re.search('hello','hello,world').span()) #在起始位置匹配
    3. print(re.search('world','hello,world').span())#不在起始位置匹配

    图片.png