Fixed spelling errors, omissions, code typos (#34145)
Added missing regex tags at the end, fixed variable name, and erased an unnecessary space at the end of some of the test strings.
This commit is contained in:
committed by
Randell Dawson
parent
1d524f9746
commit
6f04b00ea0
@ -6,7 +6,7 @@ title: Reuse Patterns Using Capture Groups
|
||||
## Hint 1:
|
||||
Given code below:
|
||||
```javascript
|
||||
let testString = "test test test ";
|
||||
let testString = "test test test";
|
||||
let reRegex =/(test)\s\1/;
|
||||
let result = reRegex.test(testString);
|
||||
```
|
||||
@ -18,16 +18,16 @@ If we were to literally translate the regex, it would look something like this:
|
||||
let re = /(test)\s\1/;
|
||||
let literalRe = /test\stest/;
|
||||
```
|
||||
Both `rea` and `literalRe` would match the same thing.
|
||||
Both `re` and `literalRe` would match the same thing.
|
||||
|
||||
## Hint 2:
|
||||
Given the code below:
|
||||
```javascript
|
||||
let testString = "test test test ";
|
||||
let testString = "test test test";
|
||||
let reRegex =/(test)(\s)\1\2\1/;
|
||||
let result = reRegex.test(testString);
|
||||
```
|
||||
will match whole `test test test` because:
|
||||
`result` will match whole `test test test` because:
|
||||
`\1` repeats (test)
|
||||
`\2` repeats (\s)
|
||||
|
||||
|
Reference in New Issue
Block a user