From: Brian Tully Date: 2004-06-23T03:55:43+09:00 Subject: Newbie question - how to replace multiple whitespace within a string? Sorry if this is too basic a question but I just inherited a handful of Ruby code and I'm looking to do something that is unbelievably simple to do with PHP or Perl, but I'm having no luck figuring out how to do it in Ruby (no thanks to "Ruby In A Nutshell"). In the middle of a Ruby script I have a loop with the variable: @user['state'] Which is populated by data from an external text file. However I'm noticing that the text file is not consistent in how it reports the user's State and will occasionally add an extra whitespace between States comprised of 2 words, e.g., "New York". 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? Thanks in advance! Regards, Brian