>>> sent = ["Valid for brunch on Saturdays and Sundays", "Valid for brunch"]
>>> sent
['Valid for brunch on Saturdays and Sundays', 'Valid for brunch']
>>> for i in sent:
if not re.search(r'(?i)(?:saturday|sunday)', i) and re.search(r'brunch', i):
print(i)
Valid for brunch
我想这样做
你可以试试这个好的。抓住这个捕获。看到了吗演示。你知道吗
https://regex101.com/r/nL5yL3/18
使用列表理解法,如果你有一个列表中的所有句子,比如
sentences
,你可以使用以下理解法:相关问题 更多 >
编程相关推荐