zbparse/flask_app/test_case/test_正则表达式2.py
2024-12-24 17:32:00 +08:00

21 lines
733 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 re
cleaned_text = """第三章 评标办法 (综合评分法)
一、评标原则
1.评标将本着公平、公正、科学、择优的原则进行。
2.依法评标、严格保密。
...
8.投标文件 含有招标人不能接受的附加条件的;
"""
end_pattern = '^(?:第[一二三四五六七八九十百千]+(?:章|部分)\s*[\u4e00-\u9fff]+|评标办法前附表|附录(?:一)?[:]|附件(?:一)?[:]|附表(?:一)?[:]'
matches = list(re.finditer(end_pattern, cleaned_text, re.MULTILINE))
if matches:
end_index = matches[-1].start()
cleaned_text = cleaned_text[:end_index]
print("匹配成功,截断后文本:")
print(cleaned_text)
else:
print("未匹配到内容。")