提取它们非常容易,只要您知道 RegEx(正则表达式)var str = "Hello world!" // The original stringvar res = str.match(/[aeiou]/gi).join("") // Extracting the vowels// If you want to get the consonants, here you go.var res2 = str.match(/[^aeiou]/gi).join("")// Logging them bothconsole.log(res)console.log(res2)
function deletevowels(str) { let result = str.replace(/[aeiou]/g, '') return result} var text = "Hi test of Replace Javascript";const a = deletevowels(text);console.log(a);