I have the following phrase:
phrase = 'My love for ict is strict' I want to find specific phrase from a list.
phrase_list = ['My love', 'ict'] How can i find the exact phrases in phrase list in the phrase string?
I tried:
for p in phrase_list: pattern = re.compile(p) result = pattern.findall(phrase) print(result) The problem is that this prints:
['My love'] ['ict','ict'] I would only want the occurrence of 'ict' that is an exact match:
['My love'] ['ict'] How can I accomplish this for a large number of phrases?
ictinstrict?