Community
    • Login

    Replace string between quotes

    Scheduled Pinned Locked Moved General Discussion
    3 Posts 2 Posters 920 Views 1 Watching
    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 Offline
      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 Offline
        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 Offline
          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

          Hello! It looks like you're interested in this conversation, but you don't have an account yet.

          Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

          With your input, this post could be even better 💗

          Register Login
          • First post
            Last post
          The Community of users of the Notepad++ text editor.
          Powered by NodeBB | Contributors