import re # 正则表达式 pattern = re.compile(r'第[一二三四五六七八九十百千]+章.*?(?:项目|服务|商务).*?要求') # 示例文本进行测试 text = """ 第一章项目技术、服务及商务要求 第二章 服务细节要求 第三章 商务处理要求 第四章 项目安排要求 第五章 安全要求 """ # 查找所有匹配 matches = pattern.findall(text) for match in matches: print(match)