From: Philip Parker Date: 2013-04-20T11:46:27+09:00 Subject: Re: Input: sentence Modify: words Output: modified sentence Thank you all! You are helping me to understand more complicated expressions. I actually did get it to work with my simple logic: #Limitations: assumes no internal punctuation (i.e. hyphens, commas, periods on abbreviations, quotes, apostrophes, etc.) #Known outputs: will return unmodified alphanumeric instances, for example "3rd". s="There are 12 chickens for 2 roosters." #get punctuation from end of sentence p=s[-1].chr #create array without end punctuation anop = s.split(p) #create the sentence no end punctuation snop = anop.join #Make initial word array equal to working output array array = output = snop.split(' ') #iterate through all words in the array. If digits then return unchanged, otherwise abbreviate as requested. $i = 0 $num = a.length while $i < $num do if a[$i].match(/\d/) then output[$i]=a[$i] else output[$i]=a[$i][0].chr + (a[$i].length-2).to_s + a[$i][-1].chr end $i +=1 end #add punctuation back to last word output[-1]<