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.
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.
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” "
That worked. Thanks!
If found this little snap that I got in my application_helper
def remove_html_tags(str)
str.gsub(/</?[^>]*>/, “”)
end
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs