+ 1

what does " /[aeiou]/gi " do in this code?

function disemvowel(str) { return str.replace(/[aeiou]/gi, ''); }

15th Mar 2022, 6:29 PM
shokin touch
1 ответ
+ 2
It's regular expression. "[aeiou]" tells the replace function to look for any of these characters and "gi" are flags that tells the function to look for match over the entire string (will otherwise break at the first match), this is the "g" flag. And the "i" flag tells it to match case insensitively. So, it would also match, A , E and so on.
15th Mar 2022, 6:46 PM
Mustafa A
Mustafa A - avatar