1、声明与非贪心的匹配。
2、表示可选的分组。用星号匹配零次或多次、一次或多次用加号匹配、用花括号匹配特定次数、贪婪与非贪婪的匹配。
实例
importre
a='wxxIxxeuieiejfsdjxxlovexxfsiewiweirxxUxxwuerowiur'
b=re.findall('xx(.*?)xx',a)
print(b)
print(type(b))
foriteminb:
print(item)
输出
['I','love','U'] <class'list'> I love U
以上就是python正则表达式问号的使用,希望对大家有所帮助。
本文教程操作环境:windows7系统、Python 3.9.1,DELL G3电脑。