Answers for "python match string regardless of case"

0

python match case example

match subject:
    case <pattern_1>:
        <action_1>
    case <pattern_2>:
        <action_2>
    case <pattern_3>:
        <action_3>
    case _:
        <action_wildcard>
Posted by: Guest on November-06-2021
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

Python Answers by Framework

Browse Popular Code Answers by Language