I am struggling with the following. I am using commands like this in my Mac terminal to test my regex:
echo 'inputstring' | sed (-E) '/s///g'
I am trying to create a regex that:
- if and only if a word ends in the letter 'o', then:
- deletes this word-final 'o'
- replaces all occurrences of the letter 'i' to 'a' in this word
In this case, the inputstring is
filo fililo felo fale and the expected output is
fal falal fel fale
I can make a regex that does either the deletion or the replacement, but do not see how to combine them. If I put a semi column between them, I don't see how to put in the conditional part.
I am also having trouble defining 'the end of the word' position. I used
\b but it doesn't seem to work (unlike
$ for end of string).