When i try to complete the text it gets 24 of the 25 vowels, the code dont get the “I” but get just the “i”, i want to know why when i take out the comas from “[a,e,i,o,u]” it can match the “I”
let quoteSample = “Beware of bugs in the above code; I have only proved it correct, not tried it.”;
let vowelRegex = /[a,e,i,o,u]/gi; // Change this line
let result = quoteSample.match(vowelRegex); // Change this line
The commas aren’t necessary inside of a character class (the technical term for the square brackets bit). For example, to match the characters ‘a’, ‘b’, or ‘c’, you would simply write [abc], not [a,b,c]. Putting the commas in there means you want to match a comma as well.
I did however try your code as-is in node using the commas, and it did match the uppercase ‘I’ as well as the comma, for a total of 26 matches.