Community
    • Login

    Replace string between quotes

    Scheduled Pinned Locked Moved General Discussion
    3 Posts 2 Posters 689 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Savvas KechagiasS
      Savvas Kechagias
      last edited by

      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:

      /* ... */
      "str1"
      /* ... */
      "str2"
      /* ... */
      "str100"
      /* ... */
      

      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

      /* ... */
      xor("str1").crypt()
      /* ... */
      xor("str2").crypt()
      /* ... */
      xor("str100").crypt()
      /* ... */
      

      Is that possible?

      astrosofistaA 1 Reply Last reply Reply Quote 0
      • astrosofistaA
        astrosofista @Savvas Kechagias
        last edited by

        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!

        1 Reply Last reply Reply Quote 4
        • Savvas KechagiasS
          Savvas Kechagias
          last edited by

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

          1 Reply Last reply Reply Quote 2
          • First post
            Last post
          The Community of users of the Notepad++ text editor.
          Powered by NodeBB | Contributors