I wrote some code to convert normal english to pig latin a few years ago. It was ~110 lines long, very buggy, and couldn't translate back.
A few days ago I rewrote it using regular expressions in just a couple lines, and now I've decided to post it.
Just for fun, I decided to do it without regex, also, and made it work just about the same, and still much shorter than my first try.
InputBox, English MsgBox, % Eng2Pig(English) return Eng2Pig(English) { static Consonants := "bcdfghjklmnpqrstvwxyz", Letters := "abcdefghijklmnopqrstuvwxyz" Loop, Parse, English { Letter := A_LoopField if (InStr(Consonants, Letter) && !Conss) EndOfWord := EndOfWord . Letter else if (!InStr(Letters, Letter) || A_Index = StrLen(English)) { if Word Word := Word . "-" . EndOfWord . "ay" PigLatin .= Word . Letter Word := EndOfWord := Conss := } else { Conss := 1 Word .= Letter } } return PigLatin } RegEng2Pig(Eng) { return RegExReplace(Eng, "i)\b([bcdfghjklmnpqrstvwxyz]*)(\w+)\b", "$2-$1ay") } Pig2Eng(Pig) { return RegExReplace(Pig, "i)\b(\w+)-([bcdfghjklmnpqrstvwxyz]*)ay\b", "$2$1") }