B
Brian Tully
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
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