标签:python基础 代码 技术 this 顺序 模式 分享 too pytho
python贪婪和非贪婪
>>> s="This is a number 234-235-22-423" >>> r=re.match(".+(\d+-\d+-\d+-\d+)",s) >>> r.group(1) ‘4-235-22-423‘ >>> r=re.match(".+?(\d+-\d+-\d+-\d+)",s) >>> r.group(1) ‘234-235-22-423‘ >>>
>>> re.match(r"aa(\d+)","aa2343ddd").group(1) ‘2343‘ >>> re.match(r"aa(\d+?)","aa2343ddd").group(1) ‘2‘ >>> re.match(r"aa(\d+)ddd","aa2343ddd").group(1) ‘2343‘ >>> re.match(r"aa(\d+?)ddd","aa2343ddd").group(1) ‘2343‘ >>>
标签:python基础 代码 技术 this 顺序 模式 分享 too pytho
原文地址:http://www.cnblogs.com/yizhenfeng168/p/6985020.html