zbparse/flask_app/test_case/test_正则表达式.py
2024-12-18 16:01:32 +08:00

26 lines
751 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import regex
begin_pattern = regex.compile(
r'第[一二三四五六七八九十]+章\s*合同|[:]清标报告|^第二卷',
regex.MULTILINE
)
# 测试示例
test_strings = [
'投标人须知正文', # 匹配
'”投标人须知正文', # 不匹配
'” 投标人须知正文', # 不匹配
'与 投标人须知正文', # 不匹配
'见 投标人须知正文', # 不匹配
'“ 投标人须知正文', # 不匹配
'供应商须知正文', # 匹配
'谈判供应商须知正文' # 匹配
]
for s in test_strings:
if begin_pattern.search(s):
print(f"匹配: {s}")
else:
print(f"不匹配: {s}")