-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.py
146 lines (99 loc) · 2.71 KB
/
script.py
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
Numbers = "0123456"
Numbers[::2]
print(Numbers[::2])
"0123456".find('1')
print("0123456".find('1'))
name = "Micheal Jackson"
name
print(name[0])
print(name[6])
print(name[13])
print(name[-1])
print(name[-15])
print(len(name))
print(name[0:4])
print(name[8:12])
print(name[::2])
print(name[0:5:2])
statement = name + " " +"Is the best"
print(statement)
print(3 * name)
name = name + " " + "Dances Pretty well."
print(name)
print("Micheal Jackson \n is the best")
print("Micheal Jackson \t is the best")
print("Micheal Jackson is \\ the best")
print(r"Micheal Jackson \ is the best")
a = "Thriller is his sixth studio album"
print("Before applying upper:", a)
b = a.upper()
print("After applying upper:", b)
a = "MICHEAL JACKSON IS THE BEST"
print("Before applying lower:", a)
b = a.lower()
print("After applying lower:", b)
a = "Micheal Jackson is the best0"
b = a.replace('Micheal',' KingKrule')
print(b)
test_string = "Hello! Micheal Jackson has: 42 Characters."
print (len(test_string))
b = test_string.replace('!',' ').replace(':',' ').replace('.', ' ')
print(b)
atrtist_name = "King Krule"
print(atrtist_name.find("Kr"))
print(atrtist_name.find("Krule"))
print(atrtist_name.find("qwertyuiop"))
splitting_string = (atrtist_name.split())
print(splitting_string)
import re
sl = "This is me testing RegEx!"
pattern = r"testing"
search_result = re.search(pattern, sl)
if search_result:
print("Match Found!!!")
print("Thank You!")
else:
print("Match Not Found!")
import re
my_pattern = r"\d\d\d\d\d\d\d\d\d\d"
text1 = "My Phone Number is 1234567890"
match = re.search(my_pattern, text1)
if match:
print("Phone number found!!!", match.group())
else:
print("No Match!")
import re
my_pattern2 = r"\W"
text2 = "Hello-world!!!"
matches = re.findall(my_pattern2,text2)
print("Mathces:",matches)
import re
s2 = "Micheal Jackson was a singer and Known as the King of Pop!!"
the_result = re.findall("as",s2)
print(the_result)
splitting_array = re.split("\s",s2)
print(splitting_array)
my_pattern3 = r"King of Pop"
replacement = "legend"
new_string = re.sub(my_pattern3, replacement, s2, flags=re.IGNORECASE)
print(new_string)
import re
the_pattern = "House number-20111"
the_pattern = re.search("\d",the_pattern)
if the_pattern:
print("Digit found in the Pattern")
else:
print("Digit not Found in the Pattern!")
import re
strl = "The quick brown fox jumps over the lazy dog."
strl2 = r"fox"
replacement_word = "bear"
new_strl = re.sub(strl2,replacement_word,strl, flags=re.IGNORECASE)
print(new_strl)
import re
strl3 = "How much wood would a woodchuck chuck, if a woodchuck could chuck wood?"
finding = re.findall("woo",strl3)
print(finding)
practice = "Lizz"
print(practice[0:2])
var = '123456789'