Page 1 of 1

Regular expression Question

Posted: Tue Sep 04, 2012 5:00 am
by pablowilks
Help
How would I find and replace instances of the following:

<url>
<loc>http://www.eg.com/product/doll-pens%2C-set-of-5.do</loc>
<lastmod>2012-08-14</lastmod>
<priority>0.5</priority>
</url>

the above formatting is exactly how it is in my file with all white spaces exactly the same.

want instances of the above to be removed completely and not replaced with anything - just to clarify, this will be all url instances that contain '%'

Also lastmod and priority are the same values in all instances

many thanks in advance.

Posted: Tue Sep 04, 2012 6:49 am
by ak47wong
Your whitespace was swallowed by the forum sofware. Next time you should use code tags:

Code: Select all

    <url>
        <loc>http://www.eg.com/product/doll-pens%2C-set-of-5.do</loc>
        <lastmod>2012-08-14</lastmod>
        <priority>0.5</priority>
    </url>
Here's one way to do what you asked. First, enable POSIX regular expression syntax in Configure > Preferences > Editor. Then do a replace as follows:

Find what: _{4}<url>\n_{8}<loc>.*%.*</loc>\n_{8}<lastmod>2012-08-14</lastmod>\n_{8}<priority>0.5</priority>\n_{4}</url>\n (replace underscores with spaces)
Replace with: (nothing)

Posted: Tue Sep 04, 2012 6:13 pm
by pablowilks
awesome, thank you ak47wong