import re arg = "jing4 gong1 sang1 zi3" arg_count = arg.count(" ") patten ="([a-z]*)\d\s?"*(arg_count+1) print patten arg_compile = re.compile(patten) match_obj = arg_compile.search(arg) print match_obj.groups()原文链接:/regex/362135.html
import re arg = "jing4 gong1 sang1 zi3" arg_count = arg.count(" ") patten ="([a-z]*)\d\s?"*(arg_count+1) print patten arg_compile = re.compile(patten) match_obj = arg_compile.search(arg) print match_obj.groups()原文链接:/regex/362135.html