Community

    • Login
    • Search
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

    Replace string between quotes

    General Discussion
    2
    3
    217
    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 Kechagias
      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?

      astrosofista 1 Reply Last reply Reply Quote 0
      • astrosofista
        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 Kechagias
          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
          Copyright © 2014 NodeBB Forums | Contributors