Replace string between quotes

  • Hello npp community!

    So, i searched the forum but was unable to find something that suits my needs.

    Lets say I have a file with many strings like:

    /* ... */
    /* ... */
    /* ... */
    /* ... */

    I want to add something before and after the quotation, but keep the content of the string, not sure if this is clear!

    Example :
    I want the above to be like

    /* ... */
    /* ... */
    /* ... */
    /* ... */

    Is that possible?

  • Hi @Savvas-Kechagias

    Yes, it is possible. The following regex does what you want given the data you provided:

    Open the Replace dialog (Ctrl + H) and type in:

    Search: ^("[^"]+")$
    Replace: xor\($1\).crypt\(\)

    Check the Wrap around option
    Select the Regular expression search mode
    Click on the Replace All button

    Have fun!

  • Oh thanks! Seems like I have to study some RegEx :)
    Appreciate your answer!

Log in to reply