在学习以下python代码时,我遇到了re.match问题: def pythonReSubDemo(): inputstr='hello 111' def add(matched): intvalue=matched.group(0) ... re.sub('\d+',add,inputstr)
def pythonReSubDemo(): inputstr='hello 111' def add(matched): intvalue=matched.group(0) ... re.sub('\d+',add,inputstr)
没有使用match来匹配任何正则表达式,为什么可以使用match.group()
正则表达式组放在圆括号中:
re.sub('(\d+)',add,inputstr)
Regex101演示
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
点击生成二维码
我来说两句