Joel Pearson wrote in post #1106334:
> I generally don't approve of doing people's homework for them, but this
> one interests me.
> I'm not very experienced with code so I bet there's an easier way to do
> this... anyway, here's my attempt:
>
> puts gets.chomp.split.map { |s|
>   letters = s.gsub(/\W/,'')
>   if [0,1,2].include? letters.length || s !~ /[A-Z]/i
>     s
>   else
>     s[/^[^A-Z]*[A-Z]/i] + ( letters.length - 2 ).to_s +
> s[/[A-Z][^A-Z]*$/i]
>   end
> }.join(' ')

Or there's:

  puts gets.chomp.gsub(/\b([a-z])([a-z]+)([a-z])\b/i){
    "#$1#{$2.length}#$3"
  }

: There are 12 chickens for 2 roosters.
T3e a1e 12 c6s f1r 2 r6s.
: It's a gosh-darned shame, really. Isn't it?
It's a g2h-d4d s3e, r4y. I1n't it?

It doesn't like "words" with underscores or numbers in.  ;)  You can 
remove the \b markers to change that.

-- 
Posted via http://www.ruby-forum.com/.