Regular expression Question

General questions about using TextPad

Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard

Post Reply
pablowilks
Posts: 2
Joined: Tue Sep 04, 2012 4:47 am

Regular expression Question

Post 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.
ak47wong
Posts: 703
Joined: Tue Aug 12, 2003 9:37 am
Location: Sydney, Australia

Post 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)
pablowilks
Posts: 2
Joined: Tue Sep 04, 2012 4:47 am

Post by pablowilks »

awesome, thank you ak47wong
Post Reply