I would like to remove all the vowels from the string excluding the first character in TypeScript.
For example 'abced' to 'abcd'.
CodePudding user response:
You could use reqexp with positive look behind
console.log('abcedufoi'.replace(/(?<=.)([aeiou])/gi, ''))
CodePudding user response:
Not sure if there is a way to do it with just regex but you can just strip the first char when replacing and add it back after.
const myString = "abced";
myString.substring(0,1) myString.substring(1).replaceAll(/[aeiou]/ig,"");
note that the regex /[aeiou]/ig
is case insensitive because of the i
after the second /