python find matching string regardless of case

Solutions on MaxInterview for python find matching string regardless of case by the best coders in the world

showing results for - "python find matching string regardless of case"
Renata
08 Nov 2016
1# credit to the Stack Overflow users in the source lin
2# with regex
3import re
4if re.search('mandy', 'Mandy Pande', re.IGNORECASE):
5   # do your stuff here
6   # Note:
7   # results = re.search('mandy', 'Mandy Pande', re.IGNORECASE)
8   # results.group(0) is the string that matched ('Mandy')
9
10# without regex
11string1 = "hi"
12string2 = "HI"
13if string1.lower() == string2.lower():
14    print("Equals!")
15else:
16    print("Different!")