def self.strip_html(str, allow = ['a','img','p','br','i','b','u','ul','li'])
str.strip!
allow_arr = allow.join('\\b|') << '|/'
tag_pat = %r,<(?:(?:/?)|(?:\s*))(?!#{allow_arr}).*?>,
str.gsub(tag_pat, ' ')
end
http://www.bigbold.com/snippets/posts/show/535
沒有留言:
張貼留言