[Rails] Re: Method to remove html escape characters from strings

2009-04-08 Thread Freddy Andersen

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@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Method to remove html escape characters from strings

2009-04-08 Thread Karl Baum
That worked.  Thanks!

On Wed, Apr 8, 2009 at 3:04 PM, Philip Hallstrom  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" ")
> => "hello & goodbye "bar" "
>
> >
>

--~--~-~--~~~---~--~~
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@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Method to remove html escape characters from strings

2009-04-08 Thread Philip Hallstrom

> 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" ")
=> "hello & goodbye "bar" "

--~--~-~--~~~---~--~~
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@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---