我想在文本文件中找到遵循特定单词顺序的行。例子:
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
我希望顺序是相同的:“客户”排在第一位,“给定”排在第三位,“下面”应该排在第六位。
这有效:
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)
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句