2018-09-30 22:01:58 +00:00
---
id: 587d7db9367417b2b2512ba6
title: Specify Only the Lower Number of Matches
challengeType: 1
2019-08-05 16:17:33 +00:00
forumTopicId: 301366
2021-01-13 02:31:00 +00:00
dashedName: specify-only-the-lower-number-of-matches
2018-09-30 22:01:58 +00:00
---
2020-11-27 18:02:05 +00:00
# --description--
2019-10-27 16:45:37 +00:00
You can specify the lower and upper number of patterns with quantity specifiers using curly brackets. Sometimes you only want to specify the lower number of patterns with no upper limit.
2020-11-27 18:02:05 +00:00
2018-09-30 22:01:58 +00:00
To only specify the lower number of patterns, keep the first number followed by a comma.
2020-11-27 18:02:05 +00:00
2021-03-03 00:12:12 +00:00
For example, to match only the string `hah` with the letter `a` appearing at least `3` times, your regex would be `/ha{3,}h/` .
2019-05-17 13:20:30 +00:00
```js
let A4 = "haaaah";
let A2 = "haah";
let A100 = "h" + "a".repeat(100) + "h";
let multipleA = /ha{3,}h/;
2021-03-03 00:12:12 +00:00
multipleA.test(A4);
multipleA.test(A2);
multipleA.test(A100);
2019-05-17 13:20:30 +00:00
```
2021-03-03 00:12:12 +00:00
In order, the three `test` calls would return `true` , `false` , and `true` .
2020-11-27 18:02:05 +00:00
# --instructions--
2021-03-03 00:12:12 +00:00
Change the regex `haRegex` to match the word `Hazzah` only when it has four or more letter `z` 's.
2020-11-27 18:02:05 +00:00
# --hints--
2018-09-30 22:01:58 +00:00
2020-11-27 18:02:05 +00:00
Your regex should use curly brackets.
```js
assert(haRegex.source.match(/{.*?}/).length > 0);
2018-09-30 22:01:58 +00:00
```
2021-03-03 00:12:12 +00:00
Your regex should not match the string `Hazzah`
2018-09-30 22:01:58 +00:00
2020-11-27 18:02:05 +00:00
```js
assert(!haRegex.test('Hazzah'));
```
2018-09-30 22:01:58 +00:00
2021-03-03 00:12:12 +00:00
Your regex should not match the string `Hazzzah`
2018-09-30 22:01:58 +00:00
```js
2020-11-27 18:02:05 +00:00
assert(!haRegex.test('Hazzzah'));
2018-09-30 22:01:58 +00:00
```
2021-03-03 00:12:12 +00:00
Your regex should match the string `Hazzzzah`
2018-09-30 22:01:58 +00:00
2020-11-27 18:02:05 +00:00
```js
assert('Hazzzzah'.match(haRegex)[0].length === 8);
```
2018-09-30 22:01:58 +00:00
2021-03-03 00:12:12 +00:00
Your regex should match the string `Hazzzzzah`
2018-09-30 22:01:58 +00:00
2020-11-27 18:02:05 +00:00
```js
assert('Hazzzzzah'.match(haRegex)[0].length === 9);
```
2018-09-30 22:01:58 +00:00
2021-03-03 00:12:12 +00:00
Your regex should match the string `Hazzzzzzah`
2020-11-27 18:02:05 +00:00
```js
assert('Hazzzzzzah'.match(haRegex)[0].length === 10);
```
2021-03-03 00:12:12 +00:00
Your regex should match the string `Hazzah` with 30 `z` 's in it.
2020-11-27 18:02:05 +00:00
```js
assert('Hazzzzzzzzzzzzzzzzzzzzzzzzzzzzzzah'.match(haRegex)[0].length === 34);
```
# --seed--
## --seed-contents--
2018-09-30 22:01:58 +00:00
```js
2019-05-03 10:05:26 +00:00
let haStr = "Hazzzzah";
2020-11-27 18:02:05 +00:00
let haRegex = /change/; // Change this line
2019-05-03 10:05:26 +00:00
let result = haRegex.test(haStr);
2018-09-30 22:01:58 +00:00
```
2019-07-18 15:24:12 +00:00
2020-11-27 18:02:05 +00:00
# --solutions--
```js
let haStr = "Hazzzzah";
let haRegex = /Haz{4,}ah/; // Change this line
let result = haRegex.test(haStr);
```