On Apr 18, 7:32 am, Peter Loftus <lof... / gmail.com> wrote:
>     val = "     hello     ".sub(/\t/, ' ')
>     puts val
>
> Cant covert tabbed spaces into regular single spaces
> Anyone have any ideas?
> --
> Posted viahttp://www.ruby-forum.com/.

The code you posted will only substitute the first tab character into
a single space.  If you want all occurrences, use String#gsub.
Secondly, if by "tabbed spaces" you mean that the string doesn't
actually contain tabs, then asking to replace the tab character (\t)
isn't going to do anything.

If, for example, you know tabs have been converted to 4 spaces, you
could do something like this val.gsub(/ {4}/, ' ').

If what you really want is just to have any whitespace converted to a
single space, you could do this: val.gsub(/\s+/, ' ')

HTH,
Chris