1import re
2pattern = re.compile('[a-zA-Z ]+') # a...z A...Z and space allowed
3message = "Weather is nice"
4if pattern.match(message).group() == message:
5 print("match")
6else:
7 print("no match")
1import re
2
3pattern = '^a...s$'
4test_string = 'abyss'
5result = re.match(pattern, test_string)
6
7if result:
8 print("Search successful.")
9else:
10 print("Search unsuccessful.")
11
1import re
2>>> m = re.search('(?<=abc)def', 'abcdef')
3>>> m.group(0)
4'def'
1import re
2xx = "guru99,education11 is fun"
3r1 = re.findall(r"^\w+",xx)
4print(r1)