I used the following function to find the exact match for words in a string.
def exact_Match(str1, word):
result = re.findall('\\b'+word+'\\b', str1, flags=re.IGNORECASE)
if len(result)>0:
return True
else:
return False
exact_Match(str1, word)
But I get an exact match for both words "award" and "award-winning" when it only should be award-winning for the following string.
str1 = "award-winning blueberries"
word1 = "award"
word2 = "award-winning"
How can i get it such that re.findall will match whole words with hyphens and other punctuations?