Boris Blaadh <nejnejnej / gmail.com> writes: > perhaps this works? > > string = <<END > Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Pellentesque > pulvinar turpis a nisi. Cras id elit. Aliquam vitae pede nec lacus > elementum lacinia. Ut aliquam vehicula sem. > END > > lead = 90 > > wordlist = string.split(' ') > > shorttext = '' > > for word in wordlist > > break if(shorttext.length + word.length > lead) > shorttext = shorttext + word + " " > > end > > # get rid of the last space > shorttext.chop! > > puts "#{shorttext}..." It is nicer to break at word boundaries in some contexts. But if it's a single word (such as a long email address), then you'd still want to show something more than "...". Maybe you can add a check for that. e.g. for string = 'john.smith / hisdomain.com', lead = 15 -- Brian Adkins http://www.lojic.com/ http://lojic.com/blog/