It looks like a lot of coders had a tough time with this problem. The solution given
here
seems like a lot of work. Fortunately, if you're up on your regular expressions, you can knock
this out easily. If you're rusty with regular expressions, this is a great opportunity to
exercise these important skills.

The first rule under year one uses the \\b character which matches with the start of a word boundary. \\bx
matches any x at the start of a word. The second rule trivially replaces all remaining occurrences of
"x" with "ks".

Year two is also trivial. we simply replace all occurrences of letter "y" with an "i". Nothing difficult there.

The rule for year three is a little more difficult. We need to replace any "c" followed immediately by an "e"
or "i" with an "s". The rule "c([ei])" matches on the "c" followed by either an "e" or an "i". By putting the
parenthesis around "[ei]" the value it matches is stored in a variable. We access the variable with $1. The
result "s$1" replaces the "c" with an "s" and then tacks on whatever the "[ei]" matched.

The rule for year four simply replaces 1 or more occurrences of the letter "c" ending with a "k" with just a "k".

We've already seen the first two rules for year 5. The final rule is a bit tricky. It matches a "c" that is
not immediately followed by an "h" with a "k".

The rule for year six is basically the same as that the first rule of year 1.

The rule for year seven is probably the most difficult. All consonants are defined by the ranges contained within
the square brackets. Note that the vowels are missing here. The group is also enclosed within parenthesis, so
we can refer to what it matches later using the variable $1. The \\1+ means that we want to match any occurrence
of 1 or more consonants. We then replace this with just the single consonant.

I hope this gives some idea of how simple the problem can be solved using regular expressions. My goal is
not to give an precise definition for any of the constructs used above, but rather just to show you how
they could be used in this example.

Thank you for taking the time to read this solution. I welcome
any feedback you may have.