Replace letters by their rank, keeping punctuation intact
Ruby 2.0, 41+1 characters

There, now it complies with the updated rules and makes prettier output.

gsub(/\w+/){$&amp;.chars.map{|c|c.ord&amp;31}*?-}


Run with -p switch:

ruby -p ord.rb &lt;&lt;&lt; "ABC! Defghi, jklmnopqr stuvwxyz"
1-2-3! 4-5-6-7-8-9, 10-11-12-13-14-15-16-17-18 19-20-21-22-23-24-25-26