fix/regex-lower-number-of-matches (#36004)

* fix/regex-lower-number-of-matches

* fix/update-guide

* fix/convert-blockquote-to-backticks
This commit is contained in:
Tom 2019-05-17 17:53:00 -05:00 committed by nik
parent d0982a951e
commit 21118bc26a
2 changed files with 12 additions and 10 deletions

View File

@ -33,19 +33,19 @@ Change the regex <code>haRegex</code> to match the word <code>"Hazzah"</code> on
```yml
tests:
- text: Your regex should use curly brackets.
testString: assert(haRegex.source.match(/{.*?}/).length > 0, 'Your regex should use curly brackets.');
testString: assert(haRegex.source.match(/{.*?}/).length > 0);
- text: Your regex should not match <code>"Hazzah"</code>
testString: assert(!haRegex.test("Hazzah"), 'Your regex should not match <code>"Hazzah"</code>');
testString: assert(!haRegex.test("Hazzah"));
- text: Your regex should not match <code>"Hazzzah"</code>
testString: assert(!haRegex.test("Hazzzah"), 'Your regex should not match <code>"Hazzzah"</code>');
testString: assert(!haRegex.test("Hazzzah"));
- text: Your regex should match <code>"Hazzzzah"</code>
testString: assert(haRegex.test("Hazzzzah"), 'Your regex should match <code>"Hazzzzah"</code>');
testString: assert("Hazzzzah".match(haRegex)[0].length === 8);
- text: Your regex should match <code>"Hazzzzzah"</code>
testString: assert(haRegex.test("Hazzzzzah"), 'Your regex should match <code>"Hazzzzzah"</code>');
testString: assert("Hazzzzzah".match(haRegex)[0].length === 9);
- text: Your regex should match <code>"Hazzzzzzah"</code>
testString: assert(haRegex.test("Hazzzzzzah"), 'Your regex should match <code>"Hazzzzzzah"</code>');
- text: Your regex should match <code>"Hazzah"</code> with 30 <code>z</code>\'s in it.
testString: assert(haRegex.test("Ha" + "z".repeat(30) + "ah"), 'Your regex should match <code>"Hazzah"</code> with 30 <code>z</code>\'s in it.');
testString: assert("Hazzzzzzah".match(haRegex)[0].length === 10);
- text: Your regex should match <code>"Hazzah"</code> with 30 <code>z</code>'s in it.
testString: assert("Hazzzzzzzzzzzzzzzzzzzzzzzzzzzzzzah".match(haRegex)[0].length === 34);
```
@ -73,7 +73,7 @@ let result = haRegex.test(haStr);
```js
let haStr = "Hazzzzah";
let haRegex = /z{4,}/; // Change this line
let haRegex = /Haz{4,}ah/; // Change this line
let result = haRegex.test(haStr);
```
</section>

View File

@ -7,6 +7,8 @@ The Problem
Change the regex haRegex to match the word "Hazzah" only when it has four or more letter z's.
Solution
```js
let haStr = "Hazzzzah";
let haRegex = /Haz{4,30}ah/; // Change this line
let haRegex = /Haz{4,}ah/; // Change this line
let result = haRegex.test(haStr);
```