Answers for "python find matching string regardless of case"

0

python find matching string regardless of case

# credit to the Stack Overflow users in the source lin
# with regex
import re
if re.search('mandy', 'Mandy Pande', re.IGNORECASE):
   # do your stuff here
   # Note:
   # results = re.search('mandy', 'Mandy Pande', re.IGNORECASE)
   # results.group(0) is the string that matched ('Mandy')

# without regex
string1 = "hi"
string2 = "HI"
if string1.lower() == string2.lower():
    print("Equals!")
else:
    print("Different!")
Posted by: Guest on September-14-2021

Code answers related to "python find matching string regardless of case"

Python Answers by Framework

Browse Popular Code Answers by Language