Commit 70c44012 by larosa

modify rex pattern

parent 405dc179
Showing with 11 additions and 3 deletions
......@@ -146,6 +146,8 @@ def match_sku(s: str) -> []:
# 此正则表达式暂时启用
# pattern = re.compile(
# r'[^0-9a-zA-Z]*([0-9a-zA-Z][0-9a-zA-Z/-]{2,})[^0-9a-zA-Z/-]*([0-9a-zA-Z][0-9a-zA-Z/-]{2,})*[^0-9a-zA-Z]*([0-9a-zA-Z][0-9a-zA-Z/-]{2,})*')
# 这里严重失误,其实正则表达式不用写这么厂,有一个很好用的方法,可以匹配出所有符合条件的字符串
patt = re.compile(r'[a-zA-Z][0-9a-zA-Z\\.,/-]{2,}') #用这个正则表达式比下面的好多了
pattern = re.compile(
r'[^0-9a-zA-Z]*([0-9a-zA-Z][0-9a-zA-Z\\.,/-]{2,})[^0-9a-zA-Z/-]*([0-9a-zA-Z][0-9a-zA-Z\\.,/-]{2,})*[^0-9a-zA-Z/-]*([0-9a-zA-Z][0-9a-zA-Z\\.,/-]{2,})*[^0-9a-zA-Z/-]*([0-9a-zA-Z][0-9a-zA-Z\\.,/-]{2,})*'
)
......@@ -244,6 +246,12 @@ def write_to_xlsx_append(info_map_list: list):
data.save('jd.xlsx')
# if __name__ == '__main__':
# res = main()
# write_to_xlsx_append(res)
if __name__ == '__main__':
res = main()
write_to_xlsx_append(res)
\ No newline at end of file
s = "东方旭普(eastsheep)2W射频衰减器SMA-JK公转母 精密型 SMA同轴衰减器20dB DC-18G 固定衰减器1个装"
pattern = re.compile(r'[a-zA-Z][0-9a-zA-Z\\.,/-]{2,}')
m = pattern.findall(s)
print(m)
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment