在看书时,关于在限定模式下使用split()分隔字符串有这样一个例子:import reDATA = ( 'Mountain wgag, CA 51676', 'wgag gage, CA', 'Gwegea, CA', 'VIOegga 81561', 'WAGA1, 1WAGA')for datum in DATA: print(re.split(',|(?= (?:\d{5}|[A-Z]{2})) ',datum))运行结果是:['Mountain wgag', '', 'CA', '51676']['wgag gage', '', 'CA']['Gwegea', '', 'CA']['VIOegga', '81561']['WAGA1', ' 1WAGA']我想知道(?= (?:\d{5}|[A-Z]{2})的具体含义,为什么它不分割WAGA?
添加回答
举报
0/150
提交
取消