class String

Public Instance Methods

strip_html_tags() click to toggle source

Returns a new string after stripping all html tags

string = "<hello>threre</hello>"

string.strip_html_tags => "there"
# File lib/liquid_markdown/core_ext/string/strip.rb, line 7
def strip_html_tags
  empty = ''.freeze
  self.to_s
      .gsub(/<script.*?<\/script>/m, empty)
      .gsub(/<!--.*?-->/m, empty)
      .gsub(/<style.*?<\/style>/m, empty)
      .gsub(/<.*?>/m, empty)
end