Search code examples
notepad++

how do i search on specific text then from start of the searched line to end of line to replace with ""


SkinMesh
{
    skin = "Art/Models/Effects/monster_effects/League_Affliction/affliction_demon_lightning/lightning_warp/geo.sm"
}

ParticleEffects
{
    animation = "start"
        0 = "midline Metadata/Particles/monster_effects/League_Affliction/affliction_demon_lightning/lightning_warp/marker_start.pet"
    animation = "loop"
        0 = "midline Metadata/Particles/monster_effects/League_Affliction/affliction_demon_lightning/lightning_warp/marker_loop.pet"
    tick_when_not_visible = true
}

What i want to from search/replace is this

SkinMesh
{
}

ParticlesEffects
{
}

Solution

    • Ctrl+H
    • Find what: (?:SkinMesh|ParticleEffects)\s+{\K.+?(?=\R})
    • Replace with: LEAVE EMPTY
    • CHECK Wrap around
    • CHECK Regular expression
    • CHECK . matches newline
    • Replace all

    Explanation:

    (?:                 # non capture group
        SkinMesh            # literally
      |                   # OR
        ParticleEffects     # literally
    )                   # end group
    \s+                 # 1 or more spaces
    {                   # opening brace
    \K                  # forget all we have seen until this position
    .+?                 # 1 or more any character, not greedy
    (?=\R})             # positive lookahead, make sure we have a linebreak and a closing brace after
    

    Screenshot (before):

    enter image description here

    Screenshot (after):

    enter image description here