johnmcauley-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-Sep-24 14:53 UTC
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 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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, "johnmcau...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org" <johnmcau...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> 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--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
what about yourstring.gsub!(/\s+/,'''') almes wrote:> 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, "johnmcau...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org" <johnmcau...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > wrote: > >> 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 >> > > > > >-- Sincerely, William Pratt --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
johnmcauley-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-Sep-25 10:44 UTC
Re: Strip White spaces
Thanks for your reply but I can not use split because there is HTML mark-up in the document that I wish to parse. On Sep 24, 6:50 pm, almes <Ally.Me...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> 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, "johnmcau...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org" <johnmcau...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > wrote: > > > 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--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
johnmcauley-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-Sep-25 10:47 UTC
Re: Strip White spaces
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? On Sep 24, 9:11 pm, William Pratt <bi...-YbheRAKfYF4eIZ0/mPfg9Q@public.gmane.org> wrote:> what about > yourstring.gsub!(/\s+/,'''') > > > > almes wrote: > > 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, "johnmcau...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org" <johnmcau...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > > wrote: > > >> 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 > > -- > Sincerely, > > William Pratt--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
johnmcauley-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-Sep-25 10:53 UTC
Re: Strip White spaces
My mistake. this works great. Thank you for your help. On Sep 25, 10:47 am, "johnmcau...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org" <johnmcau...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> 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? > > On Sep 24, 9:11 pm, William Pratt <bi...-YbheRAKfYF4eIZ0/mPfg9Q@public.gmane.org> wrote: > > > what about > > yourstring.gsub!(/\s+/,'''') > > > almes wrote: > > > 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, "johnmcau...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org" <johnmcau...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > > > wrote: > > > >> 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 > > > -- > > Sincerely, > > > William Pratt--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---