From: Brian Tully Date: 2004-06-23T04:32:11+09:00 Subject: Re: Newbie question - how to replace multiple whitespace within astring? on 6/22/04 3:01 PM, Jamey Cribbs at cribbsj@oakwood.org wrote: > Brian Tully wrote: > >> In PHP I would simply perform an eregi_replace(" ", " ", $state); and in >> Perl I would do something like $state =~ s/\s\s/\s/$state; >> >> How would one accomplish this in Ruby? >> >> > state.squeeze!(" ") > > Now, how easy is that?! :) Simply MAH-velous! :) thanks a bunch! Just to clarify... Should I use state.squeeze(" ") to ensure that it always returns the state even if nothing was changed? squeeze! seems to return nil if nothing needs to be changed. Thanks again! Brian