我想在文本文件中找到符合某些单词顺序的行。 例如:
customer is given as per below
customer are given not priority below
given given below customer
below customer information given
我试过这个(?=.*customer)(?=.*given)(?=.*below)
,但是工作。
它应该只给出
customer is given as per below
customer are given not priority below
我希望订单相同: “顾客”在第一名,“给予”在第三名,“下”应该在第六名。
答案 0 :(得分:-1)
这有效:
import re
s = '''customer is given as per below
customer are given not priority below
given given below customer
below customer information given
customer is given not as per below'''
matches = re.findall('customer \S+ given \S+\s\S+ below', s)
for match in matches:
print(match)