Home
NOTE: I'm in the middle of upgrading the site. Most things are in place, but some things are missing and/or broken. This includes alt text for images. Please bear with me while I get things fixed.

Do A Case Insensitive RexEx Search In Python

Use the [TODO: Code shorthand span ] flag to do case insenstive searches. For example, here's the same search with and without it :

import re

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

print(alfa)
print(bravo)
results start

- When doing a [TODO: Code shorthand span ] , the [TODO: Code shorthand span ] key should be called explicietly like :

re.sub('test', 'TeSt', 'source value', flags=re.IGNORECASE)

~ fin ~