I have a list of keywords to search for. Most of them are case insensitive, but a few of them are case sensitive such as IT or I.T. for information technology. Usually, I join all the keywords together with "|", and set the flag to re.I. This will cause trouble for the case-sensitive keywords. Is there an easy way to get around this? Or I have to run a separate search for the case-sensitive ones? Thank you!
keywords = ["internal control", "IT",... and many more]
patterns = r"\b(" + "|".join(keywords) + r")\b"
m = re.findall(patterns, text, flags = re.I)