-
Notifications
You must be signed in to change notification settings - Fork 0
/
deluge
240 lines (166 loc) · 3.88 KB
/
deluge
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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
product_name="Developer some Developer value Dark";
search = "Developer";
// 1 - containes
// if(product_name.indexOf(search) == -1){
// info false;
// }
// else{
// info true;
// }
// 2 - starts with
// if(product_name.indexOf(search) == 0){
// info true;
// }
// else{
// info false;
// }
// 3 - ends with
// if(product_name.lastIndexOf(search) == product_name.length() - search.length()){
// info true;
// }
// else {
// info false;
// }
// 4 - equalsIgnoreCase
// product_name="Zoho Creator";
// org_name="zoho creator";
// if(product_name.toLowerCase() == org_name.toLowerCase()){
// info true;
// }
// else{
// info false;
// }
// 5 - Get Alpha
// newProductList = product_name.toCollection("");
// result = "";
// for each new in newProductList {
// if( new.matches("[a-zA-Z]") ){
// result = result.concat(new);
// }
// }
// info result;
// 6 - getOccurenceCount
statement = "Zoho Creator is a Product";
search = "Zoho";
newCollection = statement.toList(" ");
occurance = 0;
for each item in newCollection {
if(item == search){
occurance = occurance + 1;
}
}
info occurance;
// 7 - getSuffix
product_name="Zoho Creator is a great tool for developers.";
search = "for";
newCollection = product_name.toCollection(" ");
indexOfItem = newCollection.indexOf(search);
indexOfPrev = newCollection.indexOf(search) -1;
if(indexOfPrev < 0){
info "Not found";
}
else{
info newCollection.subList(indexOfPrev,indexOfItem);
}
// 8 - getPrefix
product_name="Zoho Creator is a great tool for developers.";
search = "great";
newCollection = product_name.toCollection(" ");
indexOfPrev = newCollection.indexOf(search) -1;
start = newCollection.indexOf(search)+ 1;
end = newCollection.indexOf(search) + 2;
if(indexOfPrev < 0){
info "Not found";
}
else{
info newCollection.subList(start,end);
}
// 9 - remove
product_name="Zoho Creator is a great Tool";
remove = "creator";
newCollection = product_name.toCollection(" ");
result = "";
if(product_name.indexOf(remove) == -1){
info "not found";
}
else{
for each item in newCollection{
if(item != creator){
result = result.concat(item + " ");
}
}
info result;
}
// 10 - removeAllAlpha
product_name = "1-Red,2-Grean,3-Blue";
newCollection = product_name.toCollection("");
result = "";
for each item in newCollection{
if(item.matches("[a-zA-Z]") != true){
result = result.concat(item);
}
}
info result;
// 11 - indexOf
indexOf = statementParts.get(0).length();
if(indexOf == statement.length() ){
info -1;
} else {
info indexOf;
}
// 12 - removeFirstOccurence
product_name="Red ,Green ,Green";
search = "Green";
start = product_name.indexOf(search);
end = start + search.length();
finalResult = "";
if(product_name.indexOf(search) != -1){
result1 = product_name.subText(0,start);
result2 = product_name.subText(end,product_name.length());
finalResult = result1.concat(result2);
}
else{
info "not found";
}
info finalResult;
// 13 - removeLastOccurance
product_name="Red ,Green , Orange, Apple Green,Yellow";
search = "Green";
endPoint = product_name.lastIndexOf(search);
finalResult = "";
if(product_name.indexOf(search) != -1){
finalResult = product_name.subText(0,endPoint);
}
else{
info "not found";
}
info finalResult;
// 14- startsWithIgnoreCase
product_name="Creator Application";
search = "Application";
if(product_name.toLowerCase().indexOf(search.toLowerCase()) == 0){
info true;
}
else{
info false;
}
// 15 - endsWithIgnoreCase
product_name="Creator Application is a great tool for zoho";
search = "Zoho";
product_name_low = product_name.toLowerCase();
search_low = search.toLowerCase();
if(product_name_low.lastIndexOf(search_low) == product_name_low.length() -search_low.length()){
info true;
}
else {
info false;
}
// 16 - abs()
number= -1223123123.22;
practice = number.toCollection("");
for each item in practice{
if(item == '-'){
number = number * -1;
}
}
info number;