'^men' 标识匹配以 men 开头的字符串。
'[^mem]'标识匹配不是其中的字符串。
$ stands for matching entirely
eg:
re.match('\d&','44') ## Wrong
re.match('\d','4') ## Correct
() stands for you are preparing for obtaining sth.
eg:
a = re.match('^\w+ (\w)$','hello world')
a.groups() ## the output : ('world',)
d = re.match('^(\w+) (\w+)$','hello world')
d.groups() ## the output : ('hello','world')
re.split():
e = 'a1b2c3d4e'
re.split(r'\d',e) ## the output : ['a','b','c','d','e']
<>正则表达式
最新推荐文章于 2022-09-03 12:33:45 发布