<?xml version="1.0" encoding="utf-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>
<channel>
	<title>Comments on: Shortening strings to a fixed length in JavaScript</title>
	<atom:link href="http://www.wait-till-i.com/2006/08/25/shortening-strings-to-a-fixed-length-in-javascript/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.wait-till-i.com/2006/08/25/shortening-strings-to-a-fixed-length-in-javascript/</link>
	<description>Chris Heilmann - Accessibility, Web Development and Pragmatism - can talk, will travel</description>
	<pubDate>Fri, 05 Dec 2008 11:02:29 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5.1</generator>
		<item>
		<title>By: max</title>
		<link>http://www.wait-till-i.com/2006/08/25/shortening-strings-to-a-fixed-length-in-javascript/#comment-5608</link>
		<dc:creator>max</dc:creator>
		<pubDate>Mon, 10 Sep 2007 22:10:12 +0000</pubDate>
		<guid isPermaLink="false">#comment-5608</guid>
		<description>thanks for sharing!</description>
		<content:encoded><![CDATA[<p>thanks for sharing!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Steve Webster</title>
		<link>http://www.wait-till-i.com/2006/08/25/shortening-strings-to-a-fixed-length-in-javascript/#comment-3080</link>
		<dc:creator>Steve Webster</dc:creator>
		<pubDate>Mon, 04 Sep 2006 13:11:02 +0000</pubDate>
		<guid isPermaLink="false">#comment-3080</guid>
		<description>You can also do this with a regular expression and the String.replace method in a singe line of code:

str.replace(new RegExp("^(.{0," + n + "}\\b).*"), "$1");

The benefit of using a regular expression is that you aren't just limited to spaces separating words. The above regex will work with any character that the regular expression engine considers to be the end of a word (i.e. punctuation (other than hyphen), whitespace, etc)</description>
		<content:encoded><![CDATA[<p>You can also do this with a regular expression and the String.replace method in a singe line of code:</p>
<p>str.replace(new RegExp(&#8221;^(.{0,&#8221; + n + &#8220;}\\b).*&#8221;), &#8220;$1&#8243;);</p>
<p>The benefit of using a regular expression is that you aren&#8217;t just limited to spaces separating words. The above regex will work with any character that the regular expression engine considers to be the end of a word (i.e. punctuation (other than hyphen), whitespace, etc)</p>
]]></content:encoded>
	</item>
</channel>
</rss>
