re正则表达式6_+

+ means"match one or more"

the group proceding a plus must appear at least once.

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

This is a temporary script file.
"""
import re
re1=re.compile(r'bat(wo)+man')
mo1=re1.search("the adventure of batman")
#print("mo1.group():",mo1.group())
#出现错误,wo至少出现一次

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

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

原文地址:https://www.cnblogs.com/webRobot/p/5207424.html