Community
    • Login

    Find and Insert rather Replace

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    3 Posts 2 Posters 1.7k 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.
    • MrKeiKunM
      MrKeiKun
      last edited by MrKeiKun

      This is my original code. What I am trying to do is insert another set of codes from this:

      {
      	id: 100
      },
      {
      	info: 1000
      },
      {
      	info: 1000
      }
      

      In order to make the codes like this

      {
      	id: 100
      	info: {
      		cute: true
      	}
      },
      {
      	id: 1000
      	info: {
      		cute: true
      	}
      },
      {
      	id: 10000
      	info: {
      		cute: true
      	}
      }
      

      I used this which works fine when searching

      3e1e9545-d5b0-4659-9113-3c4400934e2f-image.png

      But I want to replace/insert the codes I want to it, it fails and this is the end result

      40d6390e-6526-4fdb-bcef-9ca1f2cde87b-image.png

      my regex might be wrong and garbage but it seems to work, the only proble mis that it replaces the regex from the search process. Is there way to avoid this?

      Alan KilbornA 1 Reply Last reply Reply Quote 0
      • Alan KilbornA
        Alan Kilborn @MrKeiKun
        last edited by Alan Kilborn

        @MrKeiKun

        You can use ${0} in your replace string to insert the contents of what was matched by the find string.
        I think that is what you are asking for.

        Alan KilbornA 1 Reply Last reply Reply Quote 4
        • Alan KilbornA
          Alan Kilborn @Alan Kilborn
          last edited by

          Another technique is to use \K at the end of your find string.
          In that usage you then do not use ${0} in the replace.
          Your replacement string will be inserted at the end of the text your find string matches.
          I mention this usage because that seems to be what you are needing.

          However, if you ever have a situation where you want your find string text to be in the middle of a replacement, then the ${0} usage is the solution.

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