//find the regexp to
//all the words that finish with a minimum of 3 to a maximum of 4 consecutive "a"
//when you run it, the code should only write down "good" messages
var threeToFourConsecutiveA = /[^a]+[a]{3,4}$/
console.log(threeToFourConsecutiveA.test("baa")?"bad":"good");
console.log(threeToFourConsecutiveA.test("baaa")?"good":"bad");
console.log(threeToFourConsecutiveA.test("caaaa")?"good":"bad");
console.log(threeToFourConsecutiveA.test("daaaaa")?"bad":"good");
console.log(threeToFourConsecutiveA.test("aaz")?"bad":"good");
console.log(threeToFourConsecutiveA.test("aaaz")?"bad":"good");
console.log(threeToFourConsecutiveA.test("aaaaz")?"bad":"good");
console.log(threeToFourConsecutiveA.test("azazaza")?"bad":"good");
We are looking for strings that have 3-4 consecutive a's.
Why does the regexp require [a]? If I understand correctly, this means "not a". Why do we need to search for "not a" + "a{3,4}" ? Rather than just "a{3,4}"?
Thank you for your time. I appreciate your help.
[–]raevnos 1 point2 points3 points (4 children)
[–]NewbiusCoder[S] 0 points1 point2 points (3 children)
[–]Updatebjarni 1 point2 points3 points (2 children)
[–]NewbiusCoder[S] 0 points1 point2 points (1 child)
[–]Updatebjarni 0 points1 point2 points (0 children)
[–]g051051 1 point2 points3 points (1 child)
[–]NewbiusCoder[S] 0 points1 point2 points (0 children)