博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
rails过滤html
阅读量:4042 次
发布时间:2019-05-24

本文共 864 字,大约阅读时间需要 2 分钟。

strip_links
(html)

Strips all link tags from text leaving just the link text.

Examples strip_links('<a href="http://www.rubyonrails.org">Ruby on Rails</a>')
# => Ruby on Rails
strip_links('Please e-mail me at <a href="mailto:me@email.com">me@email.com</a>.')
# => Please e-mail me at me@email.com.
strip_links('Blog: <a href="http://www.myblog.com/" class="nav" target=\"_blank\">Visit</a>.')
# => Blog: Visit

]

strip_tags
(html)

Strips all HTML tags from the html, including comments. This uses the html-scanner tokenizer and so its HTML parsing ability is limited by that of html-scanner.

Examples strip_tags("Strip <i>these</i> tags!")
# => Strip these tags!
strip_tags("<b>Bold</b> no more! <a href='more.html'>See more here</a>...")
# => Bold no more! See more here...
strip_tags("<div id='top-bar'>Welcome to my website!</div>")
# => Welcome to my website!

转载地址:http://cdadi.baihongyu.com/

你可能感兴趣的文章
1076. Forwards on Weibo (30)
查看>>
1079. Total Sales of Supply Chain (25)
查看>>
1025. PAT Ranking (25)
查看>>
1048. Find Coins (25)
查看>>
1049. Counting Ones (30)计算个位数出现次数.
查看>>
1059. Prime Factors (25)
查看>>
1089. Insert or Merge (25)
查看>>
1068. Find More Coins (30)
查看>>
相邻两数最大差值练习题
查看>>
拓扑结构相同子树练习题
查看>>
字符串空格替换练习题
查看>>
最长无重复字符子串练习题
查看>>
获取栈中最小值函数,时间复杂度为O(1)
查看>>
两个栈实现一个队列
查看>>
栈的反转
查看>>
栈的排序,栈顶元素最大.
查看>>
next数组计算.
查看>>
队列的滑动窗口最大值练习题.
查看>>
数组变树练习题
查看>>
打印两个链表的公共值练习题
查看>>