import re
# compile(pattern, flags=0)编译,一般用于同一个正则被调用多次
content = '''<title>this is python</title>'''
res = re.compile('<title>([\w\W]*)</title>')
res.match(content)
# 后面的方法都是re模块提供的,但是使用compile也可以使用,只要注意传参就可以了
# flages参数值:
re.compile('', flags=re.I) # 大小写不敏感
res = re.compile('aa', flags=re.I)
print(res.match('Aa'))
re.compile('', flags=re.S) # 点的任意匹配模式,改变'.'的行为
re.compile('', flags=re.L) # 使预定字符类 \w \W \b \B \s \S 取决于当前区域设定
re.compile('', flags=re.M) # 多行模式,改变'^'和'$'的行为
re.compile('', flags=re.X) # 详细模式。这个模式下正则表达式可以是多行,忽略空白字符,并可以加入注释
re.compile('', flags=re.U) # 使预定字符类 \w \W \b \B \s \S \d \D 取决于unicode定义的字符属性