我想从字符串中获取十进制数字,但后面不跟“/套”。
pattern = '(\d{1,}\.{0,1}\d{0,}万{0,1}-{0,1}\d{0,}\.{0,1}\d{0,}万{0,1})元{0,1}(?!/套)'
string1 = 'item 1:298元/套起'
string2 = 'item 1:298元/m2起'
string3 = 'item 1:298/m2起'
result1 = re.findall(pattern, string1) #expected [], but return ['1', '298']
result2 = re.findall(pattern, string2) #expected [298], but return ['1', '298', '2']
result3 = re.findall(pattern, string3) #expected [298], but return ['1', '298', '2']
如何得到正确答案?
慕妹3146593
红糖糍粑
相关分类