正则表达式使用Notepad ++替换XML标记之间的文本

时间:2015-05-05 07:34:31

标签: html regex replace find notepad++

使用Notepad ++

替换XML标记之间的文本的正则表达式

我需要替换所有网址标记,如果 / mailto / 与Notpad ++中的""

我需要在html标签之间查找和替换文本。例如:

的xml:

 <urlset>
    <url>
        <loc>http://www.file3.ir/last-books/183-Education/The-Praeger-Handbook-of-Learning-and-the-Brain-%5B2-volumes%5D</loc>
        <lastmod>2015-05-02T21:15:06+00:00</lastmod>
        <priority>0.00</priority>
        <changefreq>monthly</changefreq>
    </url>
    <url>
        <loc>http://www.file3.ir/last-books/183-Education/Learning-JavaScript</loc>
        <lastmod>2015-05-02T21:15:06+00:00</lastmod>
        <priority>0.00</priority>
        <changefreq>monthly</changefreq>
    </url>
    <url>
        <loc>http://www.file3.ir/last-books/Category/183-Education/?start=868</loc>
        <lastmod>1970-01-01T21:15:06+00:00</lastmod>
        <priority>0.00</priority>
        <changefreq>monthly</changefreq>
    </url>
    <url>
        <loc>http://www.file3.ir/component/mailto/?tmpl=component&amp;template=jm_plus&amp;link=4ae20e207319a25c17f554db7a4e9fa6f2694865</loc>
        <lastmod>2015-05-02T21:15:06+00:00</lastmod>
        <priority>0.00</priority>
        <changefreq>monthly</changefreq>
    </url>
    <url>
        <loc>http://www.file3.ir/component/mailto/?tmpl=component&amp;template=jm_plus&amp;link=034b3c240db5c92e676bdf91b7b4bdffd725c428</loc>
        <lastmod>2015-05-02T21:15:06+00:00</lastmod>
        <priority>0.00</priority>
        <changefreq>monthly</changefreq>
    </url>
    <url>
        <loc>http://www.file3.ir/component/mailto/?tmpl=component&amp;template=jm_plus&amp;link=c704ffd88b576782f9135da4848ab22a3cfb0f53</loc>
        <lastmod>2015-05-02T21:15:06+00:00</lastmod>
        <priority>0.00</priority>
        <changefreq>monthly</changefreq>
    </url>
    <url>
        <loc>http://www.file3.ir/component/mailto/?tmpl=component&amp;template=jm_plus&amp;link=6b28532ecf1950b9e755938e65c1a1b6e466483e</loc>
        <lastmod>1970-01-01T21:15:06+00:00</lastmod>
        <priority>0.00</priority>
        <changefreq>monthly</changefreq>
    </url>
    <url>
        <loc>http://www.file3.ir/component/mailto/?tmpl=component&amp;template=jm_plus&amp;link=a0ed06a8c2e075dbf1c1a23ae9203b2b464b166c</loc>
        <lastmod>1970-01-01T21:15:06+00:00</lastmod>
        <priority>0.00</priority>
        <changefreq>monthly</changefreq>
    </url>
    <url>
        <loc>http://www.file3.ir/component/mailto/?tmpl=component&amp;template=jm_plus&amp;link=63e8e699f6db77096398c390d78fa1cd1ee34b6c</loc>
        <lastmod>1970-01-01T21:15:06+00:00</lastmod>
        <priority>0.00</priority>
        <changefreq>monthly</changefreq>
    </url>
    <url>
        <loc>http://www.file3.ir/component/mailto/?tmpl=component&amp;template=jm_plus&amp;link=3a52445764cd71cad0a389f13b53faf5ae3a7dc5</loc>
        <lastmod>2015-05-02T21:15:06+00:00</lastmod>
        <priority>0.00</priority>
        <changefreq>monthly</changefreq>
    </url>
    <url>
        <loc>http://www.file3.ir/component/mailto/?tmpl=component&amp;template=jm_plus&amp;link=9ea60360f4a81636f1e13f3a4e734016317d6179</loc>
        <lastmod>2015-05-02T21:15:06+00:00</lastmod>
        <priority>0.00</priority>
        <changefreq>monthly</changefreq>
    </url>
    <url>
        <loc>http://www.file3.ir/component/mailto/?tmpl=component&amp;template=jm_plus&amp;link=42c96ca4e0c746bd9155234a619be95300714953</loc>
        <lastmod>2015-05-02T21:15:06+00:00</lastmod>
        <priority>0.00</priority>
        <changefreq>monthly</changefreq>
    </url>
<url>
    <loc>http://www.file3.ir/last-books/183-Education/Technical-Math-Demystified</loc>
    <lastmod>2015-05-02T21:15:06+00:00</lastmod>
    <priority>0.00</priority>
    <changefreq>monthly</changefreq>
</url>
</urlset>

替换后:

    <url>
        <loc>http://www.file3.ir/last-books/183-Education/The-Praeger-Handbook-of-Learning-and-the-Brain-%5B2-volumes%5D</loc>
        <lastmod>2015-05-02T21:15:06+00:00</lastmod>
        <priority>0.00</priority>
        <changefreq>monthly</changefreq>
    </url>
    <url>
        <loc>http://www.file3.ir/last-books/183-Education/Learning-JavaScript</loc>
        <lastmod>2015-05-02T21:15:06+00:00</lastmod>
        <priority>0.00</priority>
        <changefreq>monthly</changefreq>
    </url>
    <url>
        <loc>http://www.file3.ir/last-books/Category/183-Education/?start=868</loc>
        <lastmod>1970-01-01T21:15:06+00:00</lastmod>
        <priority>0.00</priority>
        <changefreq>monthly</changefreq>
    </url>
<url>
        <loc>http://www.file3.ir/last-books/183-Education/Technical-Math-Demystified</loc>
        <lastmod>2015-05-02T21:15:06+00:00</lastmod>
        <priority>0.00</priority>
        <changefreq>monthly</changefreq>
    </url>

</urlset>

帮帮我......

1 个答案:

答案 0 :(得分:2)

您可以使用以下内容:

  • 找到:<url>[^<]+?<loc>[^<]+?/mailto/[^<]+?</loc>.+?</url>
  • 搜索模式:Regular Expression。请务必核对. matches newline

这应该删除你所追求的块。然后,您可以执行以下操作:Edit - &gt; Line Operations - &gt; Remove Empty Lines (Containing Blank Characters)清除您的意见。

相关问题