From: tamouse mailing lists Date: 2013-04-21T16:01:43+09:00 Subject: Re: Input: sentence Modify: words Output: modified sentence On Sat, Apr 20, 2013 at 8:49 AM, Joel Pearson wrote: > 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 These little exercises are great for playing around with things.