Javascript: Edited hint to Specify Only the Lower Number of Matches (#19245)
* Javascript: Edited hint to Specify Only the Lower Number of Matches Edited hint to Specify Only the Lower Number of Matches * Update index.md
This commit is contained in:
committed by
Quincy Larson
parent
169e0ee582
commit
e73c360476
@ -1,18 +1,21 @@
|
|||||||
|
---
|
||||||
|
title: Specify Only the Lower Number of Matches
|
||||||
---
|
---
|
||||||
title: Specify Only the Lower Number of Matches
|
|
||||||
---
|
|
||||||
The Problem
|
|
||||||
Change the regex haRegex to match the word "Hazzah" only when it has four or more letter z's.
|
|
||||||
|
|
||||||
Solution
|
|
||||||
let haStr = "Hazzzzah";
|
|
||||||
let haRegex = /Haz{4,30}ah/; // Change this line
|
|
||||||
let result = haRegex.test(haStr);
|
|
||||||
|
|
||||||
## Specify Only the Lower Number of Matches
|
## Specify Only the Lower Number of Matches
|
||||||
|
|
||||||
This is a stub. <a href='https://github.com/freecodecamp/guides/tree/master/src/pages/certifications/javascript-algorithms-and-data-structures/regular-expressions/specify-only-the-lower-number-of-matches/index.md' target='_blank' rel='nofollow'>Help our community expand it</a>.
|
### The Problem:
|
||||||
|
|
||||||
<a href='https://github.com/freecodecamp/guides/blob/master/README.md' target='_blank' rel='nofollow'>This quick style guide will help ensure your pull request gets accepted</a>.
|
Change the regex ```haRegex``` to match the word ```"Hazzah"``` only when it has four or more letter ```z```'s.
|
||||||
|
|
||||||
<!-- The article goes here, in GitHub-flavored Markdown. Feel free to add YouTube videos, images, and CodePen/JSBin embeds -->
|
### Solution:
|
||||||
|
|
||||||
|
```js
|
||||||
|
let haStr = "Hazzzzah";
|
||||||
|
let haRegex = /Haz{4,}ah/; // Change this line
|
||||||
|
let result = haRegex.test(haStr);
|
||||||
|
```
|
||||||
|
|
||||||
|
### Explanation:
|
||||||
|
|
||||||
|
We specify the lower and upper number of patterns with ```quantity specifiers``` using curly brackets - lower is ```4``` and unlimited upper number.
|
||||||
|
Reference in New Issue
Block a user