如果内容以字符串开头并以某个字符串结尾,则从该字符串中删

时间:2015-08-29 23:28:24

标签: regex vb.net

你好,我对这个正则表达式有点麻烦

我想删除以下列

开头和结尾的所有内容

以:-->

开头

结束于:<!-- <rdf:RDF xmlns:rdf="/web/20120124023607/http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dc="/web/20120124023607/http://purl.org/dc/elements/1.1/" xmlns:trackback="/web/20120124023607/http://madskills.com/public/xml/rss/module/trackback/"> <rdf:Description rdf:about="/web/20120124023607/http://www.flatfeets.com/flat-feet-foot-definition/" dc:identifier="/web/20120124023607/http://www.flatfeets.com/flat-feet-foot-definition/" dc:title="What Is Flat Feet Or Flat Foot ?" trackback:ping="/web/20120124023607/http://www.flatfeets.com/flat-feet-foot-definition/trackback/" /> -->

要删除的字符串示例:

 Function StripGarbage(ByVal article As String) As String
        Return Regex.Replace(article, "<!--(.+?)-->", "")
    End Function

我的代码无效:

{{1}}

1 个答案:

答案 0 :(得分:2)

使用[\S\s]代替.,它允许正则表达式跨多行匹配