python – How to match a substring in a string, ignoring case
python – How to match a substring in a string, ignoring case
If you dont want to use str.lower()
, you can use a regular expression:
import re
if re.search(mandy, Mandy Pande, re.IGNORECASE):
# Is True
Theres another post here. Try looking at this.
BTW, youre looking for the .lower()
method:
string1 = hi
string2 = HI
if string1.lower() == string2.lower():
print Equals!
else:
print Different!
python – How to match a substring in a string, ignoring case
Try:
if haystackstr.lower().find(needlestr.lower()) != -1:
# True