Strip White spaces

Hello All,

I am trying to strip white spaces out of a html file or a very long
string and am coming up a blank. Does anyone have some suggestions as
to how to tackle this?

Regards,

j

I am sure there is a more elegant solution but I think the following
could work:

your_string.squeeze(" “).split(” ").join

On Sep 24, 9:53 am, “[email protected][email protected]

what about
yourstring.gsub!(/\s+/,’’)

almes wrote:

Hello All,


Sincerely,

William P.

The problem with this approach is that it removes all spaces form the
document, which is not my intention. I wish to remove all white
spaces from the document while retaining all spaces between words.
Does anybody know how to do this?

My mistake. this works great.

Thank you for your help.

On Sep 25, 10:47 am, “[email protected][email protected]

Thanks for your reply but I can not use split because there is HTML
mark-up in the document that I wish to parse.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs