From: "Florian Groß" Date: 2005-07-09T12:33:41+09:00 Subject: Re: truncate a string to first 200 characters luke wrote: > i'm looking for something that can take a string and truncate it to a > certain amount of characters. then i can add '...' at the end. > > i used to use substr() when working with php > > $str = substr( $str, 0, 200) . "..."; The most correct way of doing this IMHO is this: str += "..." if str.slice!(200 .. -1) which will cut away everything after the first 200 characters and append a marker if the string was truncated. Your PHP solution would map to this: str = str[0, 200] + "..."