Search after 2 character and delete alle between



  • Hi

    Can Notepad ++ does this:
    Search for 2 character and delete these two character and all between ?

    Example
    Search after “(” and “)”
    Results:
    (summer)
    (sun)
    (flower)

    and delete all instances of:
    (summer)
    (sun)
    (flower)



  • Hello Steen-Frank-Mikkelsen,

    one way would be to use regular expressions with replace dialog.
    When dialog has been opened check Regular Expression in
    Search Mode section.
    Then put the following in Find what: (()(.*)())
    and in Replace with: \1\3

    Cheers
    Claudia



  • Hello, Steen Frank Mikkelsen and Claudia,

    I think that the correct regex S/R should be :

    • \(.*?\) in the Find what : zone

    • Nothing in the Replace with : zone

    with the Regular expression search mode checked, of course !

    Notes :

    • The two round brackets, that have to be matched, must be escaped with a backslash character, in order to be taken literally, as there are special regex characters, which define a group

    • The syntax .*? represents the shortest string of characters, between the two round brackets

    • The other syntax .* would have matched the largest string, between two round brackets. So, it could contain round brackets, itself !

    Best Regards,

    guy038



  • oopps, I thought ( ) should remain, but if I reread it clearly states
    Search for 2 character and delete these two character and all between ?

    Cheers
    Claudia


Log in to reply