From: Joel Pearson Date: 2013-04-20T22:49:13+09:00 Subject: Re: Input: sentence Modify: words Output: modified sentence Building on what Matthew and tamouse demonstrated (I didn't know about the block form before), I've come up with this: code: _____ puts gets.chomp.gsub( /\b([[:alpha:]'\-&&[^\d]])([[:alpha:]'\-&&[^\d]]{1,})([[:alpha:]'\-&&[^\d]])\b/ ) { "#{ $1 }#{ $2.length }#{ $3 }" } _____ input: "There won't be a cul-de-sac on 2nd St. until April 3, 2015. But, we'll be waiting." output: "T3e w3t be a c8c on 2nd St. u3l A3l 3, 2015. B1t, w3l be w5g." We could go on refining this forever with unusual use cases :p -- Posted via http://www.ruby-forum.com/.