def has_href_not_XXX?(content)
content = content.dup
loop do
content.sub!(/href=(['"])([^'"]+)\1/, "")
if $2.blank?
return false
else
if (!$2[".XXX.com"])
return true
end
end
end
end
ruby 正则匹配非站内链接
最新推荐文章于 2025-11-23 15:07:29 发布
本文介绍了一个Ruby方法,用于检查HTML内容中的href属性是否包含特定的字符串(例如:'.XXX.com')。该方法通过正则表达式匹配并移除所有href属性值,如果剩余的属性值中不含'.XXX.com',则返回真。

870

被折叠的 条评论
为什么被折叠?



