Match Characters that Occur One or More Times

Tell us what’s happening:

Omg this is hard I don’t know what to do?

Your code so far



let chewieQuote = "Mississippi";
let chewieRegex = /a*/; // Change this line
let result = chewieQuote.match(chewieRegex);// Change this line

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36.

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/regular-expressions/match-characters-that-occur-one-or-more-times

Regex is tough! It makes more sense the more you do it.

My suggestion for your code is this:

The * after a character will match 0 or more times.

As the + character will match a character 1 or more times.

Then, the challenge wants you to find all the matches. A flag would help here.

I hope this helps and good luck!

Please can you explain me more easy.

Look this so simple if you remember these rule for constructing Regex.

Modifier Description
i Perform case-insensitive matching
g Perform a global match (find all matches rather than stopping after the first match)
m Perform multiline matching




Quantifier Description
n+ Matches the preceding expression 1 or more times.
n* Matches the preceding expression 0 or more times.

For example, /a+/ matches the 'a' in "candy" and all the a's in "caaaaaaandy", but nothing in "cndy".
For example, /bo*/ matches 'boooo' in "A ghost booooed" and 'b' in "A bird warbled" but nothing in "A goat grunted".

Hope this help to you !!

What code I can use?

Look this code !!!

let difficultSpelling = “Mississippi”;
let myRegex = /s+/ig; // Change this line
let result = difficultSpelling.match(myRegex);

ohh yes this is right thank you and your way to explain me it it so simple>

1 Like