# Only supported 3.10+
# _ is the symbol for wildcard
match value:
case Case1:
...
case Case2:
...
case (5, _): # if value is some tuple with first element 5
...
case _: # you can implement a fall-through like this
...
class Point:
x: int
y: int
def where_is(point):
match point:
case Point(x=0, y=0):
print("Origin")
case Point(x=0, y=y):
print(f"Y={y}")
case Point(x=x, y=0):
print(f"X={x}")
case Point():
print("Somewhere else")
case _:
print("Not a point")
# import re module
import re
Substring ='string'
String1 ='''We are learning regex with geeksforgeeks
regex is very useful for string matching.
It is fast too.'''
String2 ='''string We are learning regex with geeksforgeeks
regex is very useful for string matching.
It is fast too.'''
# Use of re.search() Method
print(re.search(Substring, String1, re.IGNORECASE))
# Use of re.match() Method
print(re.match(Substring, String1, re.IGNORECASE))
# Use of re.search() Method
print(re.search(Substring, String2, re.IGNORECASE))
# Use of re.match() Method
print(re.match(Substring, String2, re.IGNORECASE))