我有一個文本文件和一個包含單詞列表的數組。我需要找到一種方式,在這種情況下,我可以過濾掉出現超過1個句子的句子。我只是無法制定如何編寫代碼。這裏有一個例子:Perl - 捕獲一個數組中出現多個元素的句子
輸入:
my @strings = (
"i'm going to find the occurrence of two words if possible",
"i'm going to find the occurrence of two words if possible",
"to find a solution to this problem",
"i will try my best for a way to this problem"
);
my @words = ("find", "two", "way");
輸出:
i'm going to find the occurrence of two words if possible
i'm going to find the occurrence of two words if possible
而且我也知道這是一個簡單的問題,但我的心似乎已經打了路障。
它應該與「find find」匹配嗎? – ikegami
理想情況下,它應該匹配'find'和'two',但'find'和'find'也是合理的。 – ary
這是一個是或否的問題... – ikegami