In python, how can I make a regular expression that would match all capitalization combinations of a word, without formatting the data before hand. For example, let's say I want to match lines in a file that match the word name, however it is capitalized. That is, name could look like any of the following
Make sure to pass the
re.IGNORECASE option when calling your match, find or search.
For your example it'd be something like:
import re re.search('name', 'Name', re.IGNORECASE) re.search('name', 'nAMe', re.IGNORECASE) re.search('name', 'NAme', re.IGNORECASE)