📜  仅在字符串 Javascript 代码示例中查找元音

📅  最后修改于: 2022-03-11 15:03:49.787000             🧑  作者: Mango

代码示例1
//This function accepts a string and 
//returns a new string that (matches all vowels) and displays these vowels as such
//Using built in method and RegEx
//Hope this helps:)

function is vowelsOnly(str) {
return  str.match(/[aeiou]/ig, '');
}

console.log(vowelsOnly("hello world"));//['e', 'o', 'o']
console.log(vowlesOnly("SHOUT it out"));//['O','U','i','o','u']