0

I am trying to delete all the vowels from a string within a function.

deleteVowels = myString.replace(/[aeiou]/i, "");

Deletes a,e,i,o,u from the string, however instead of (/[aeiou]/i), I want to pass in a value instead which is:

let vowels = "aeiou";

I have tried things such as:

deleteVowels = myString.replace(/[vowels]/i, ""); // and many other variatons.

I have searched SO and found similar, however, not being able to pass in a string keeping the letters separate. Would appreciate some support as I may be barking up the wrong tree here. Thanks

  • 2
    Perhaps [this](https://stackoverflow.com/questions/494035/how-do-you-use-a-variable-in-a-regular-expression) – Yarin_007 Jan 04 '23 at 23:14

0 Answers0