Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
岳巧源
/
my-awesome-project
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
70c44012
authored
Jun 22, 2024
by
larosa
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
modify rex pattern
parent
405dc179
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
3 deletions
main.py
main.py
View file @
70c44012
...
...
@@ -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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment