How To Search For A String Case-insensitively Without Regular Expressions?
I want to search a file for all lines containing a given string without matching case. How can I make this code case-insensitive? with open(logfile) as inf: for line in inf:
Solution 1:
with open(logfile) as fin:
for line in fin:
if var.lower() in line.lower(): # makes this case insensitive
print 'found', line.rstrip() # You will be printing double new lines
# without rstrip here
Post a Comment for "How To Search For A String Case-insensitively Without Regular Expressions?"