Is there a convenient way of removing html escape characters from Strings? I could do using reg exp as in: => "hello & goodbye">> "hello & goodbye".gsub(/&/, "&")=> "hello & goodbye" but I figured there might be a better way. thx. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Philip Hallstrom
2009-Apr-08 19:04 UTC
Re: Method to remove html escape characters from strings
> Is there a convenient way of removing html escape characters from > Strings? I could do using reg exp as in: > > => "hello & goodbye" >>> "hello & goodbye".gsub(/&/, "&") > => "hello & goodbye" > > but I figured there might be a better way.require ''CGI''>> require ''CGI'' => true >> CGI::unescapeHTML("hello & goodbye "bar" <baz>") => "hello & goodbye "bar" <baz>" --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
That worked. Thanks! On Wed, Apr 8, 2009 at 3:04 PM, Philip Hallstrom <philip-LSG90OXdqQE@public.gmane.org> wrote:> > > Is there a convenient way of removing html escape characters from > > Strings? I could do using reg exp as in: > > > > => "hello & goodbye" > >>> "hello & goodbye".gsub(/&/, "&") > > => "hello & goodbye" > > > > but I figured there might be a better way. > > require ''CGI''>> require ''CGI'' > => true > >> CGI::unescapeHTML("hello & goodbye "bar" <baz>") > => "hello & goodbye "bar" <baz>" > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Freddy Andersen
2009-Apr-08 20:58 UTC
Re: Method to remove html escape characters from strings
If found this little snap that I got in my application_helper def remove_html_tags(str) str.gsub(/<\/?[^>]*>/, "") end --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---