How to disemvowel a string with a condition where if the letter “g” is right beside a vowel, it would also be considered a vowel?

前端 未结 3 1783
别跟我提以往
别跟我提以往 2021-01-27 17:29

Working on a homework question where all the vowels in a string need to be removed and if the letter \"g\" is beside a vowel, it would also be considered a vowel. For example gi

3条回答
  •  暖寄归人
    2021-01-27 18:09

    Interesting, does this stack?

    So if you had the word baggga, would the outer g's turn into vowels, which then would turn the inner g also into a vowel? So is the output bg or is it b?

    You can either remove all g's next to vowels and then in a second step remove all vowels.

    Or you could replace all g's next to vowels by, let's say 'a', and then remove all vowels. If the 'g is a vowel'-rule stacks, you may have to repeat the first step until the string does not change anymore.

提交回复
热议问题