I have two lists of different sizes. One has Product Titles and other one has brand names ( may be one word or more). I need to check if the Product Title has exact brand name(present in brand list) mentioned and extract the same else return empty list. Am facing issue in extracting matching Brand name because brand may contain multiple words.
For eg. : Following is the input:
Product_Titles =[['Best abc def hair oil'],['laptop erg eds ram 15 GB'],['oops dfr watch']]
Brand_List = [['abc def'],['dfe sdf sd'],['erg eds']]
#Expected Output :
Brand = [['abc def'],['erg eds'],[]]
Getting an empty list for third Product Title because we were not able to get any matching brand with Brand_List.
P.S. :
Only if the complete Brand Name matches then we should return Brand Name.
I have tried Regex but it's not working because if we have 'str' in brand list and 'string' in Product Titles, it will give 'string' as Brand. But I need exact output.
Thanks a ton for all wonderful answers ! I have combined all the below suggestions and came up with my version of the same.
Solution :