Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
eshiled-new
/
my_flask_web
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 1485e23a
authored
Jan 17, 2024
by
杨林龙
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
优化车架号校验
1 parent
a461f67c
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
2 deletions
test01.py
test01.py
View file @
1485e23
...
@@ -2,7 +2,8 @@ import re
...
@@ -2,7 +2,8 @@ import re
def
extract_vin
(
string
):
def
extract_vin
(
string
):
pattern
=
r"(?=.*[0-9A-HJ-NPR-Z])(?!(.*[IOQ]))([0-9A-HJ-NPR-Z]{17})"
# pattern = r"(?=.*[0-9A-HJ-NPR-Z])(?!(.*[IOQ]))([0-9A-HJ-NPR-Z]{17})"
pattern
=
r"(?=.*[0-9A-HJ-NPR-Z])(?!(.*[IOQ]))([0-9A-HJ-NPR-Z\s\u4e00-\u9fa5]{17})"
match
=
re
.
search
(
pattern
,
string
)
match
=
re
.
search
(
pattern
,
string
)
if
match
:
if
match
:
vin
=
match
.
group
()
vin
=
match
.
group
()
...
@@ -12,6 +13,8 @@ def extract_vin(string):
...
@@ -12,6 +13,8 @@ def extract_vin(string):
# 测试字符串
# 测试字符串
test_string
=
"This is a test VIN: 1HGCM82633A123456 GT800"
# test_string = "This is a test VIN: 1HGCM82633A123456 GT800"
test_string
=
"test 这是一段包含车架号的文本:1HGCM82633A123456"
# test_string = "1HGCM82633A123456"
result
=
extract_vin
(
test_string
)
result
=
extract_vin
(
test_string
)
print
(
result
)
# 输出 1HGCM82633A123456
print
(
result
)
# 输出 1HGCM82633A123456
Write
Preview
Markdown
is supported
Attach a file
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 post a comment