Python正则使用 Posted on 2018-07-27 | Edited on 2018-07-29 | In Python 导入正则:re1import re match1234567#match匹配的过程是从左第一个字符向右逐一匹配的,当匹配的过程出现不符合字符时,即停止匹配过程,相当于匹配表达式中设置了"^"re.match(pattern,str)In [34]: re.match(r"aa(\d+?)ddd","aa1234ddd").group(1)Out[34]: '1234' Read more »