Search code examples
replacenotepad++wildcard

Replacing a file extension and everything after it using wildcards in Notepad++


What I have:

<object class="imageSettings" data="../assets/FOM_SVG_140.svg" height="434.501282" style="max-width: 100%;height: auto;display: block;margin: auto;" type="image/svg+xml" width="486.747274">

What I want:

<object class="imageSettings" data="../assets/FOM_SVG_140.png >

I have numerous SVG files with different information between .svg and >. Is there an easy way to replace the text? I've tried various wildcards, but I haven't gotten the desired result. I'm fairly new to wild cards. I've tried:

.svg*>
\.svg.*$
\svg.+$
\svg.*$

Solution

    • Ctrl+H
    • Find what: \.svg".+?>
    • Replace with: .png">
    • TICK Match case
    • TICK Wrap around
    • SELECT Regular expression
    • UNTICK . matches newline
    • Replace all

    Explanation:

    \.svg       # extension, dot have to be escaped
    "           # double quote
    .+?         # 1 or more any character, not greedy
    >           # close tag
    

    Screenshot (before):

    enter image description here

    Screenshot (after):

    enter image description here