Note: This site is currently "Under construction". I'm migrating to a new version of my site building software. Lots of things are in a state of disrepair as a result (for example, footnote links aren't working). It's all part of the process of building in public. Most things should still be readable though.

Do A Case Insensitive RexEx Search In Python

Use the `re.IGNORECASE`` flag to do case insenstive searches. For example, here's the same search with and without it:

Code

import re

alfa  = re.search('test', 'TeSt')
bravo = re.search('test', 'TeSt', re.IGNORECASE)

print(alfa)
print(bravo)

Results

None
<re.Match object; span=(0, 4), match='TeSt'>