You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Your program must exit with 0 if a digit is found in the string, and 1 if not.
100
-
101
-
### Notes
102
-
103
-
- To learn how Regexes work under the hood, you'll build your own regex implementation from scratch instead of using {{language_name}}'s built-in regex features.
104
-
105
-
{{#reader_is_bot}}
106
-
Do not use `grep` or the regex utilities available in the standard library. Implement the regex matcher yourself.
107
-
{{/reader_is_bot}}
108
85
marketing_md: |-
109
86
In this stage, we'll implement support for the `\d`
In this stage, we'll add support for [positive character groups](https://docs.microsoft.com/en-us/dotnet/standard/base-types/character-classes-in-regular-expressions#positive-character-group--).
155
-
156
-
Positive character groups match any character that is present within a pair of square brackets.
157
-
158
-
**Example:** `[abc]` should match "apple", but not "dog".
159
-
160
-
Your program will be executed like this:
161
-
162
-
```bash
163
-
$ echo -n "apple" | ./your_program.sh -E "[abc]"
164
-
```
165
-
166
-
Your program must exit with 0 if an any of the characters are found in the string, and 1 if not.
167
-
168
-
{{#reader_is_bot}}
169
-
Do not use `grep` or the regex utilities available in the standard library. Implement the regex matcher yourself.
170
-
{{/reader_is_bot}}
171
111
marketing_md: |-
172
112
In this stage, we'll add support for [positive character groups](https://docs.microsoft.com/en-us/dotnet/standard/base-types/character-classes-in-regular-expressions#positive-character-group--).
173
113
@@ -180,24 +120,6 @@ stages:
180
120
- slug: "rk3"
181
121
name: "Negative Character Groups"
182
122
difficulty: medium
183
-
description_md: |-
184
-
In this stage, we'll add support for [negative character groups](https://docs.microsoft.com/en-us/dotnet/standard/base-types/character-classes-in-regular-expressions#negative-character-group-).
185
-
186
-
Negative character groups match any character that is not present within a pair of square brackets.
187
-
188
-
**Example:** `[^abc]` should match "dog", but not "cab" (since all characters are either "a", "b" or "c").
189
-
190
-
Your program will be executed like this:
191
-
192
-
```bash
193
-
$ echo -n "apple" | ./your_program.sh -E "[^abc]"
194
-
```
195
-
196
-
Your program must exit with 0 if the input contains characters that aren't part of the negative character group, and 1 if not.
197
-
198
-
{{#reader_is_bot}}
199
-
Do not use `grep` or the regex utilities available in the standard library. Implement the regex matcher yourself.
200
-
{{/reader_is_bot}}
201
123
marketing_md: |-
202
124
In this stage, we'll add support for [negative character groups](https://docs.microsoft.com/en-us/dotnet/standard/base-types/character-classes-in-regular-expressions#negative-character-group-).
203
125
@@ -210,34 +132,6 @@ stages:
210
132
- slug: "sh9"
211
133
name: "Combining Character Classes"
212
134
difficulty: medium
213
-
description_md: |-
214
-
In this stage, we'll add support for patterns that combine the character classes we've seen so far.
215
-
216
-
This is where your regex matcher will start to _feel_ useful.
217
-
218
-
Keep in mind that this stage is harder than the previous ones. You'll likely need to rework your
219
-
implementation to process user input character-by-character instead of the whole line at once.
220
-
221
-
We recommend taking a look at the example code in ["A Regular Expression Matcher"](https://www.cs.princeton.edu/courses/archive/spr09/cos333/beautiful.html)
222
-
by Rob Pike to guide your implementation.
223
-
224
-
**Examples:**
225
-
226
-
- `\d apple` should match "1 apple", but not "1 orange".
227
-
- `\d\d\d apple` should match "100 apples", but not "1 apple".
228
-
- `\d \w\w\ws` should match "3 dogs" and "4 cats" but not "1 dog" (because the "s" is not present at the end).
Your program must exit with 0 if the pattern matches the input, and 1 if not.
237
-
238
-
{{#reader_is_bot}}
239
-
Do not use `grep` or the regex utilities available in the standard library. Implement the regex matcher yourself.
240
-
{{/reader_is_bot}}
241
135
marketing_md: |-
242
136
In this stage, we'll support patterns that combine the character classes we've seen so far.
243
137
@@ -253,24 +147,6 @@ stages:
253
147
- slug: "rr8"
254
148
name: "Start of string anchor"
255
149
difficulty: medium
256
-
description_md: |-
257
-
In this stage, we'll add support for `^`, the [Start of String or Line anchor](https://docs.microsoft.com/en-us/dotnet/standard/base-types/anchors-in-regular-expressions#start-of-string-or-line-).
258
-
259
-
`^` doesn't match a character, it matches the start of a line.
260
-
261
-
**Example:** `^log` should match "log", but not "slog".
262
-
263
-
Your program will be executed like this:
264
-
265
-
```bash
266
-
$ echo -n "log" | ./your_program.sh -E "^log"
267
-
```
268
-
269
-
Your program must exit with 0 if the input starts with the given pattern, and 1 if not.
270
-
271
-
{{#reader_is_bot}}
272
-
Do not use `grep` or the regex utilities available in the standard library. Implement the regex matcher yourself.
273
-
{{/reader_is_bot}}
274
150
marketing_md: |-
275
151
In this stage, we'll add support for `^`, the [Start of String or Line anchor](https://docs.microsoft.com/en-us/dotnet/standard/base-types/anchors-in-regular-expressions#start-of-string-or-line-).
276
152
@@ -283,24 +159,6 @@ stages:
283
159
- slug: "ao7"
284
160
name: "End of string anchor"
285
161
difficulty: medium
286
-
description_md: |-
287
-
In this stage, we'll add support for `$`, the [End of String or Line anchor](https://learn.microsoft.com/en-us/dotnet/standard/base-types/anchors-in-regular-expressions#end-of-string-or-line-).
288
-
289
-
`$` doesn't match a character, it matches the end of a line.
290
-
291
-
**Example:** `dog$` should match "dog", but not "dogs".
292
-
293
-
Your program will be executed like this:
294
-
295
-
```bash
296
-
$ echo -n "dog" | ./your_program.sh -E "dog$"
297
-
```
298
-
299
-
Your program must exit with 0 if the input matches the given pattern, and 1 if not.
300
-
301
-
{{#reader_is_bot}}
302
-
Do not use `grep` or the regex utilities available in the standard library. Implement the regex matcher yourself.
303
-
{{/reader_is_bot}}
304
162
marketing_md: |-
305
163
In this stage, we'll add support for `$`, the [End of String or Line anchor](https://learn.microsoft.com/en-us/dotnet/standard/base-types/anchors-in-regular-expressions#end-of-string-or-line-).
306
164
@@ -313,22 +171,6 @@ stages:
313
171
- slug: "fz7"
314
172
name: "Match one or more times"
315
173
difficulty: hard
316
-
description_md: |-
317
-
In this stage, we'll add support for `+`, the [one or more](https://docs.microsoft.com/en-us/dotnet/standard/base-types/quantifiers-in-regular-expressions#match-one-or-more-times-) quantifier.
318
-
319
-
**Example**: `a+` should match "apple" and "SaaS", but not "dog".
320
-
321
-
Your program will be executed like this:
322
-
323
-
```bash
324
-
$ echo -n "caats" | ./your_program.sh -E "ca+ts"
325
-
```
326
-
327
-
Your program must exit with 0 if the input matches the given pattern, and 1 if not.
328
-
329
-
{{#reader_is_bot}}
330
-
Do not use `grep` or the regex utilities available in the standard library. Implement the regex matcher yourself.
331
-
{{/reader_is_bot}}
332
174
marketing_md: |-
333
175
In this stage, we'll add support for `+`, the [one or more](https://docs.microsoft.com/en-us/dotnet/standard/base-types/quantifiers-in-regular-expressions#match-one-or-more-times-) quantifier.
334
176
@@ -339,22 +181,6 @@ stages:
339
181
- slug: "ny8"
340
182
name: "Match zero or one times"
341
183
difficulty: hard
342
-
description_md: |-
343
-
In this stage, we'll add support for `?`, the [zero or one](https://learn.microsoft.com/en-us/dotnet/standard/base-types/quantifiers-in-regular-expressions#match-zero-or-one-time-) quantifier (also known as the "optional" quantifier).
344
-
345
-
**Example**: `dogs?` should match "dogs" and "dog", but not "cat".
346
-
347
-
Your program will be executed like this:
348
-
349
-
```bash
350
-
$ echo -n "dogs" | ./your_program.sh -E "dogs?"
351
-
```
352
-
353
-
Your program must exit with 0 if the input matches the given pattern, and 1 if not.
354
-
355
-
{{#reader_is_bot}}
356
-
Do not use `grep` or the regex utilities available in the standard library. Implement the regex matcher yourself.
357
-
{{/reader_is_bot}}
358
184
marketing_md: |-
359
185
In this stage, we'll add support for `?`, the [zero or one](https://learn.microsoft.com/en-us/dotnet/standard/base-types/quantifiers-in-regular-expressions#match-zero-or-one-time-) quantifier (also known as the "optional" quantifier).
360
186
@@ -365,22 +191,6 @@ stages:
365
191
- slug: "zb3"
366
192
name: "Wildcard"
367
193
difficulty: medium
368
-
description_md: |-
369
-
In this stage, we'll add support for `.`, which matches any character.
370
-
371
-
**Example**: `d.g` should match "dog", but not "cog".
372
-
373
-
Your program will be executed like this:
374
-
375
-
```bash
376
-
$ echo -n "dog" | ./your_program.sh -E "d.g"
377
-
```
378
-
379
-
Your program must exit with 0 if the input matches the given pattern, and 1 if not.
380
-
381
-
{{#reader_is_bot}}
382
-
Do not use `grep` or the regex utilities available in the standard library. Implement the regex matcher yourself.
383
-
{{/reader_is_bot}}
384
194
marketing_md: |-
385
195
In this stage, we'll add support for `.`, which matches any character.
386
196
@@ -391,22 +201,6 @@ stages:
391
201
- slug: "zm7"
392
202
name: "Alternation"
393
203
difficulty: hard
394
-
description_md: |-
395
-
In this stage, we'll add support for the `|` keyword, which allows combining multiple patterns in an either/or fashion.
396
-
397
-
**Example**: `(cat|dog)` should match "dog" and "cat", but not "apple".
Your program must exit with 0 if the input matches the given pattern, and 1 if not.
406
-
407
-
{{#reader_is_bot}}
408
-
Do not use `grep` or the regex utilities available in the standard library. Implement the regex matcher yourself.
409
-
{{/reader_is_bot}}
410
204
marketing_md: |-
411
205
In this stage, we'll add support for the `|` keyword, which allows combining multiple patterns in an either/or fashion.
412
206
@@ -420,30 +214,6 @@ stages:
420
214
primary_extension_slug: "backreferences"
421
215
name: "Single Backreference"
422
216
difficulty: hard
423
-
description_md: |
424
-
In this stage, we'll add support for backreferences.
425
-
426
-
A backreference lets you reuse a captured group in a regular expression. It is denoted by `\` followed by a number, indicating the position of the captured group.
427
-
428
-
**Examples:**
429
-
- `(cat) and \1` should match "cat and cat", but not "cat and dog".
430
-
- `\1` refers to the first captured group, which is `(cat)`.
431
-
- `(\w+) and \1` should match "cat and cat" and "dog and dog", but not "cat and dog".
432
-
- `\1` refers to the first captured group, which is `(\w+)`.
Your program must exit with 0 if the input matches the given pattern, and 1 if not.
441
-
442
-
**Note:** You only need to focus on one backreference and one capturing group in this stage. We'll get to handling multiple backreferences in the next stage.
443
-
444
-
{{#reader_is_bot}}
445
-
Do not use `grep` or the regex utilities available in the standard library. Implement the regex matcher yourself.
446
-
{{/reader_is_bot}}
447
217
marketing_md: |
448
218
In this stage, you'll add support for single backreferences. You'll implement support for `\1`.
449
219
@@ -454,24 +224,6 @@ stages:
454
224
primary_extension_slug: "backreferences"
455
225
name: "Multiple Backreferences"
456
226
difficulty: medium
457
-
description_md: |
458
-
In this stage, we'll add support for multiple backreferences.
459
-
460
-
Multiple backreferences allow you to refer to several different captured groups within the same regex pattern.
461
-
462
-
**Example:** `(\d+) (\w+) squares and \1 \2 circles` should match "3 red squares and 3 red circles" but should not match "3 red squares and 4 red circles".
In this stage, we'll add support for backreferences.
2
+
3
+
A backreference lets you reuse a captured group in a regular expression. It is denoted by `\` followed by a number, indicating the position of the captured group.
4
+
5
+
**Examples:**
6
+
-`(cat) and \1` should match "cat and cat", but not "cat and dog".
7
+
-`\1` refers to the first captured group, which is `(cat)`.
8
+
-`(\w+) and \1` should match "cat and cat" and "dog and dog", but not "cat and dog".
9
+
-`\1` refers to the first captured group, which is `(\w+)`.
Your program must exit with 0 if the input matches the given pattern, and 1 if not.
18
+
19
+
**Note:** You only need to focus on one backreference and one capturing group in this stage. We'll get to handling multiple backreferences in the next stage.
20
+
21
+
{{#reader_is_bot}}
22
+
Do not use `grep` or the regex utilities available in the standard library. Implement the regex matcher yourself.
In this stage, we'll add support for multiple backreferences.
2
+
3
+
Multiple backreferences allow you to refer to several different captured groups within the same regex pattern.
4
+
5
+
**Example:**`(\d+) (\w+) squares and \1 \2 circles` should match "3 red squares and 3 red circles" but should not match "3 red squares and 4 red circles".
0 commit comments