From: Robert Klemme Date: 2008-12-03T19:05:57+09:00 Subject: Re: Substring with "..." 2008/12/2 Jose Antonio Parra : > Thaks. The method is truncate. I used that but I couldn't remember the > name. Jim, I had alredy looked at the String class, but no method do > that. There *is* a method in class String - kind of: irb(main):009:0> w = ["a", "b" * 17, "c" * 20, "d" * 25] => ["a", "bbbbbbbbbbbbbbbbb", "cccccccccccccccccccc", "ddddddddddddddddddddddddd"] irb(main):010:0> x = w.map {|s| s.sub(%r{\A(.{17}).{4,}\z}, '\\1...')} => ["a", "bbbbbbbbbbbbbbbbb", "cccccccccccccccccccc", "ddddddddddddddddd..."] irb(main):011:0> x.map {|s| s.length} => [1, 17, 20, 20] ;-) Kind regards robert -- remember.guy do |as, often| as.you_can - without end