-
re.match(pattern, string, flags)
- 作用:只匹配字符串的开始部分
- pattern:正则表达式,匹配成功返回Match,否则返回None
- string:字符串
- flags:匹配方式,如:区分大小写等
-
re.search(pattern, string, flags)
- 作用:匹配整个字符串
- 参数与re.match一样
-
re.sub(pattern, repl, string, count)
- 作用:替换匹配到的字符串
- repl:替换的字符
- count:替换个数
-
re.split()
- 作用:分割字符串
-
re.findall()
- 作用:获取所有包含字符的字符串
-
re.compile()
- 把正则表达式编译成正则表达式对象
08-08
08-08
08-08