-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathsession6-2.py
More file actions
65 lines (41 loc) · 1.13 KB
/
Copy pathsession6-2.py
File metadata and controls
65 lines (41 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import re
if re.search("inform", " We need to inform him with the inform latest information"):
print("There is inform")
allinform = re.findall("inform", "We need to inform him with the inform latest information")
for i in allinform:
print(i)
str = "We need to inform him with the inform latest information"
for i in re.finditer("inform", str):
loc = i.span()
print(loc)
str = "Sat, hat, mat, pat, zat"
# allstr = re.findall("[shmp]at",str)
allstr = re.findall("[H-Mh-m]at",str)
for i in allstr:
print(i)
regex = re.compile("[m]at")
food = regex.sub("food",str)
print(food)
randostr='''
Keep the blue flag
flying high
Chelesa'''
print(randostr)
regex = re.compile("\n")
randstr = regex.sub(" ",randostr)
print(randstr)
#\b backspace
#\t tab
#\v verrtical tab
marks = "12345"
print("Matches: ",len(re.findall("\D", marks)))
marks1 = "123 1234 12345 123456 1234567"
print("Matches1: ",len(re.findall("\d{5,7}", marks1)))
#\w [a-zA-Z0-9_]
#\W [^a-zA-Z0-9_]
phone="412-5555-1212"
if re.search("\d{3}-\d{3}-\d{4}",phone):
print("phone number is valid")
phones = "123"
out = re.findall("[^0-9]",phone)
print(out)