Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JavaScript Strip Vowels

I am trying to strip vowels in a string. I know I should be using str.replace but I am baffled on how to get it into a span.

This is more of less what i am looking to do:

Write a JavaScript function that takes in a string s and returns the string which is equivalent to s but with all ASCII vowels removed. EX: (“Hello World”) returns: "Hll wrld"

Please help!

like image 641
user1825293 Avatar asked Dec 11 '12 22:12

user1825293


People also ask

How do you remove consonants from a string in Java?

Core Java bootcamp program with Hands on practice Similarly, the following expression matches all the consonants in the given input string. "([^aeiouyAEIOUY0-9\W]+)"; Then you can remove the matched characters by replacing them with the empty string “”, using the replaceAll() method.


1 Answers

.replace(/[aeiou]/ig,'') is all you need.

like image 172
Niet the Dark Absol Avatar answered Nov 16 '22 02:11

Niet the Dark Absol