+ 1
Removing vowels in a string
I’m trying to do a javacsript code so it can remove all the vowels from a string. However I’m facing some difficulties, there must be something from javascript that I didn’t understand that well. I know how to check is one variable is similar or not to another, bit checking if a specific character is among a string is quite nervewrecking. Could you please tell me how to do it ? Thank you
3 Réponses
+ 2
If str is your string try something like :
str.replace(/[aeiou]/gi, '');
[aeiou] : all vowels
g modifier: global. All matches (don't return after first match)
i modifier: insensitive. Case insensitive match (ignores case of [a-zA-Z])
Try the expression /[aeiou]/gi in one site with regular like :
https://regexr.com/
to understand more
0
I have to admit that your solution work. Thank you for that. However I was hoping for a little more complex code with loops, arrays etc.. to understand the logic
0
In that case, please post your code here so we can give you opinion on which lines to change