user1876508 user1876508 - 2 years ago 122
Python Question

How to use regular expressions in python to search for all capitalization combinations

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



Answer Source

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'name', 'Name', re.IGNORECASE)'name', 'nAMe', re.IGNORECASE)'name', 'NAme', re.IGNORECASE)
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download