正则_星号匹配零次或多次

2018-08-20  本文已影响0人  测试媛617
import re
batRegex = re.compile(r'Bat(wo)*man')
mo1 = batRegex.search('The Adventures of Batman')
print(mo1.group())

mo2 = batRegex.search('The adventures of Batwoman')
print(mo2.group())

mo3 = batRegex.search('the adventures of Batwowowowoman')
print(mo3.group())
结果是:
Batman
Batwoman
Batwowowowoman
上一篇 下一篇

猜你喜欢

热点阅读