re正则表达式5_*

时间:2021-02-02 03:41:01

*表示匹配[0,正无穷大]次

* means math zero or more-----occur any number of times in the text.

# -*- coding: utf-8 -*-
"""
Spyder Editor

This is a temporary script file.
"""
import re
message="the adventure of batman"
re1=re.compile(r'bat(wo)*man')
mo1=re1.search("the adventure of batman")
print("mo1.group():",mo1.group())

mo2=re1.search("the adventure of batwoman")
print("mo2.group():",mo2.group())

mo3=re1.search("the adventure of batwowowowoman")
print("mo3.group():",mo3.group())

re正则表达式5_*