Regular Expressions - Match Characters that Occur One or More Times

Tell us what’s happening:
Describe your issue in detail here.

In this topic there is a wrong explanation:

abc will return [“a”] (RIGHT!!!)
aabc will return [“aa”] (Wrong when doing in practically!!!)

Your code so far

let difficultSpelling = "aabab";
let myRegex = /[a+]/g; // Change this line
let result = difficultSpelling.match(myRegex);
console.log(result); //the result must be ["aa","a"] but the output is different

Your browser information:

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

Challenge: Regular Expressions - Match Characters that Occur One or More Times

Link to the challenge:

Hi there and welcome to the forum!

Why is this wrong? The string ‘aabc’ does return ‘aa’ when matched using the regex /a+/g.

1 Like

by mistake i did programming mistake, sorry please delete it

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.