Here's the shortest that I could come up with:
Points to note:
- It handles multiple consonants at the start of the word (i.e. "this" comes "isthay")
- It handles 'qu'.
- It's terribly inefficient, but then, I guess that wasn't the point :)
Here's the full breakdown, if anyone's interested:
my $test = "that is the time for all good men to come to the aid of th
\b # start of word
( # capture all to $1
( # this is $2
qu # word starts with qu
| # or
[bcdfghjklmnpqrstvwxyz]+ # a consonent
)? # but it's optional
( # this is $3
[a-z]+ # rest of word
/$2 ? $3.$2."ay" : $1."way" /xeg; # if $2 evaluates as true
# put it at end of word an
+d add "ay"
# otherwise, just add "way
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.
| & || & |
| < || < |
| > || > |
| [ || [ |
| ] || ] ||