Strip HTML in Ruby on Rails

To remove all HTML tags from string

string = "Bob"

string = string.gsub(/<\/?[^>]*>/, '')


To remove HTML image tag from string

string = string.gsub(/<_i_m_g_[^>]+>/ ,'') . (Note:-> Please remove underscores from "_i_m_g_" make it "img" only)

No comments

Powered by Blogger.