From: Patrick Doyle Date: 2009-01-10T03:57:19+09:00 Subject: Re: Q: most efficient way to remove duplicate spaces in a string? --0022152d7ddf0711a6046011554e Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit On Fri, Jan 9, 2009 at 1:24 PM, Mark Watson wrote: > I don't usually worry too much about efficiency unless runtime > performance becomes an issue so I use a_string.split.join(' ') to > remove extra spaces because the code is short and readable. > > This is certainly inefficient. What is the fastest idiom for this > operation? > I was looking at the docs the other day and stumbled across String#squeeze. You might try benchmarking that. --wpd --0022152d7ddf0711a6046011554e--