My requirement in simple plain English
Match if keyword inside a string starts/ends or both with non-alphanumeric words, or exact match
Keyword: china
'CHINA', #match
'CHINA ROM' #match
'CHINA WAREHOUSE', #match
'CHINA-WAREHOUSE', #match
'CHINA-ROM', #match
'dsa china', #match
'CHINALOCAL', #No
'CHINAOO' #No
As per my current knowledge of Regexes, I can do something like
keyword = keyword.lower()
if keyword == '' string \
or re.match(r"china[^a-zA-Z0-9]", keyword, flags=re.IGNORECASE) \
or re.match(r"[^a-zA-Z0-9]china", keyword, flags=re.IGNORECASE) \
or re.match(r"[^a-zA-Z0-9]china[^a-zA-Z0-9]", keyword, flags=re.IGNORECASE):
print("matched")
Is there any single regex expression that can perform all checks I want?