The following is a way to match the keyword from the results, but is not every time can be 100% accurate
Search_words_dict = { "enteritis Ning": 0,"Vitamin Ad": 0,"gynecological daughter": 0,"Honeysuckle Dew": 0,"Raw vein Drink": 0,"Bone Thong paste": 0,"37 Injury Pills": 0,"Children's Cold granules": 0,}keys=Search_words_dict.keys () array_str=")| (". Join (keys) Array_str=". * (%s). *"%Array_str#array = ". *) | (. * ". Join (keys)#array = "(. *%s.*)"% arrayStrss ="compound women's and gold Peanuts Shandong Province vein Drink dew Chisang Shengmai drink children Cold granule injury Pills Gold Press more Nao that"pattern=re.compile (ARRAY_STR)Print("The content of the regular is:%s"%pattern)ifRe.search (Pattern, strss):Print(Re.search (pattern, strss))Else: Print("So sorry")
The second way, this way, it's a lot more.
Search_words_dict = { "enteritis Ning": 0,"Vitamin Ad": 0,"gynecological daughter": 0,"Honeysuckle Dew": 0,"Raw vein Drink": 0,"Bone Thong paste": 0,"37 Injury Pills": 0,"Children's Cold granules": 0,}keys=Search_words_dict.keys ()#array_str = ") | (". Join (keys)#array_str = ". * (%s). *"% array_str#pattern = re.compile (ARRAY_STR)Array =".*)| (.*". Join (keys) array="(. *%s.*)"%Arraypattern=re.compile (array) Strss="compound women's and gold peanut Shandong Province vein Drink dew Chisang children Cold granule injury Pills Gold Press more Nao that"Print("The content of the regular is:%s"%pattern)ifRe.search (Pattern, strss):Print(Re.search (pattern, strss))Else: Print("So sorry")
From the result: the match is all
Regular Expression Python