-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathquiz.txt
206 lines (182 loc) · 4.31 KB
/
quiz.txt
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
Purpose:
This is supposed to be a learning process. The first 1-9 tasks are supposed to be done with using "standard" regex, ie, teach the user to use \s, \w, \d, aswell as backrefs and similar basic things.
Later down the road, at task 10-13 we start introducing them to lookarounds. These are fairly basic for now.
At task 14-15 we show them the true power of lookarounds and encourage them to use them properly and what can truly be done with them.
Task 16 and forward is supposed to introduce \G and other nifty ideas. This is where its supposed to be more advanced and trickier.
Task order:
1: Word Boundaries
2: Capitalize i
3: Uppercase Consonants
4: Retreive Numbers
5: Whitespaces
6: Broken Keyboard
7: Validate an IP
8: Html Tags
9: Validate floating numbers
10: Followed by #
11: Spam filter
12: Match an E-Mail (Simplified)
13: Not surrounded by digits
14: Repeated words
15: start before end
16: Every other digit
17: The thousands
18: Quoted text with escapes
19: Replace text, not code
20: Tokenized list
21: Replace in between - Match * inside square brackets
22: Outermost Brackets
Task 1: Word Boundaries
Strings:
word valid
aworda invalid
thisisnotaword invalid
wordnot invalid
wor invalid
wOrdd invalid
WORD valid
WORDz invalid
zWORD invalid
Valid regex:
/\bword\b/i
Task 2: Capitalize
Strings:
I am a cat invalid (questionable)
this is invalid invalid
i am a cat valid -> I am a cat
capitalize this i valid -> capitalize this I
abc i abc valid -> abc I abc
ii i ii valid -> ii I ii
i valid -> I
abc i abc i abc i abc valid -> abc I abc I abc I abc
Valid regsub:
/\bi\b/g I
Task 3: Uppercase Consonants
Strings:
BCDFGHJKLMNPQRSTVXZ valid
Valid regex:
/[B-DF-HJ-NP-TV-Z]/g
Task 4: Retreive Numbers
Strings:
12345 valid -> 12345
12abc12 valid -> 12, 12
1a2b3 valid -> 1, 2, 3
Valid Regex:
/(\d+)/g
Task 5: Whitespaces
Strings:
??
Valid regex:
/[ ]{4}/S
Task 6: Match a e-mail (simplified)
Strings:
@someone.com invalid
a.@com invalid
.a@.com invalid
.@.com invalid
.@abc.com invalid
email@.a.com invalid
mail@mail.com valid
()[]\;:,<>@example.com invalid
A@b@c@example.com invalid
abc@abc.loooong invalid
abc@abc.abc.com valid
Valid regex:
/^[\w.%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i
Task 7: Validate an IP
Strings:
too lazy for this one lol
Valid regex:
/^(?:(?:[01]?\d?\d|2[0-4]\d|25[0-5])\.){3}(?:[01]?\d?\d|2[0-4]\d|25[0-5])$/
Task 8: HTML Tags
Strings:
...
Valid regex:
/<[^>]*|[^<]*>/g
Task 9: Validate floating numbers
Strings:
1.0 valid
12,123 valid
+10 valid
-0.1 valid
-.1 valid
-1.5e20 valid
+50e1 valid
+20.0 valid
+1.01e10 valid
+1. invalid
+1 valid
.+1 invalid
1.4e10 valid
1.4.e10 invalid
. invalid
.e0 invalid
Valid regex:
/^[+-]?(?:\d+(?:\.(?!$))?|\.)\d*(?:e\d+)?$/ need update
Task 10: Broken keyboard
Strings:
...
Valid regex:
/(.)\1\1/
Task 11: Followed by #
Strings:
...
Valid regex:
/(.)(?=#)/g
Task 12: Spam filter
Strings:
...
Valid regex:
/^(?!.*(filter|mirc|not allowed)).*(?:http:\/\/|www\.|porn|credit card)/i
Task 13: Not surrounded by digits
Strings:
...
Valid regex:
/(?<!\d)\.|\.(?!\d)/g
Task 14: Repeated words
Strings:
...
Valid regex:
/(\b\w{4,}\b)(?=(?:.*\b\1\b){2})(?!(.*\b\1\b){3})/ig
Task 15: start before end
Strings:
...
Valid regex:
/^(?:(?!end).)*start/
Task 16: Every other digit
Strings:
...
Valid regsub:
/\G((?:.\D)*.)\d/g \1*
Task 17: The thousands
Strings:
100 invalid
1000 valid -> 1,000
9999 valid -> 9,999
12345 valid -> 12,345
9999999999999999 valid -> 9,999,999,999,999,999
Valid regsub:
/(\d)(?=(\d{3})+\b)/ \1,
Task 18: Quoted text with escapes
Strings:
...
Valid regex:
/^"((?>\\.|[^"])*)"$/
Task 21: Match * inside square brackets
Strings:
...
Valid regex/regsub:
/^([^[]+)|([^]]+)$|(\][^[]+\[)|\*/ \1\2\3
/(?(?=^)[^]]*\[\K|(?(?=\])..*?\[\K|\*))/g
Task 22: Outermost Brackets
Strings:
...
Valid regex:
/(\((?>[^()]+|(?R))+\))/g
Task 23: Validate string with X lower case and X upper case characters.
Left to document:
Match regex
Match a valid mathematical expression
Highlight text with colors (maintaining current color codes)
Palindromes
Ignoring punctuation