In [59]: s = 'hello World!'
In [60]: regex = re.compile("hello world!", re.I)
In [61]: regex.match(s).group()
Out[61]: 'hello World!'
re.M MULTILINE,多行模式, 改变 ^ 和 $ 的行为
In [63]: s
Out[63]: 'first line\nsecond line\nthird line'
In [64]: pattern=re.compile(r'^\w+')
In [65]: re.findall(pattern,s)
Out[65]: ['first']
In [67]: pattern=re.compile(r'^\w+',re.M)
In [68]: re.findall(pattern,s)
Out[68]: ['first', 'second', 'third']
In [62]: s = '''first line
...: second line
...: third line'''
In [71]: regex=re.compile('.+',re.S)
In [73]: regex.findall(s)
Out[73]: ['first line\nsecond line\nthird line']
In [74]: regex=re.compile('.+')
In [75]: regex.findall(s)
Out[75]: ['first line', 'second line', 'third line']