• Login
Community
  • Login

Find&replace, RegEx, \10

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
6 Posts 4 Posters 2.3k 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.
  • G
    Gergely Apró
    last edited by Jan 24, 2021, 6:00 PM

    I want to find&replace using regular expression.
    If I put (something) in find and then \number to replace then the text in the bracket won’t be changed. I have 14 brackets in a single command. And when I write \10 to the replace, it return the first bracket and a zero, rather than the stuff in the 10th bracket.

    A P 2 Replies Last reply Jan 24, 2021, 6:21 PM Reply Quote 0
    • A
      astrosofista @Gergely Apró
      last edited by Jan 24, 2021, 6:21 PM

      @Gergely-Apró

      If I correctly understood your question, just enclose it in brackets, as in \{10}.

      Take care and have fun!

      A 1 Reply Last reply Jan 24, 2021, 6:41 PM Reply Quote 0
      • A
        Alan Kilborn @astrosofista
        last edited by Jan 24, 2021, 6:41 PM

        @astrosofista said in Find&replace, RegEx, \10:

        \{10}

        I don’t think that syntax works??

        But this syntax ALWAYS works, in replace:

        ${1} <-- for group 1
        ${2} <-- for group 2
        …
        ${N} <-- for group N

        Thus for OP’s specific problem and example --> ${10} in replace field should work.

        A A 2 Replies Last reply Jan 24, 2021, 6:58 PM Reply Quote 3
        • A
          Alan Kilborn @Alan Kilborn
          last edited by Alan Kilborn Jan 24, 2021, 6:58 PM Jan 24, 2021, 6:58 PM

          I neglected to mention the “group 0” match, which has the same syntax format as the ones I DID mention:

          If you happen to need to refer to ALL of the matched text, you can use ${0} to refer to it.

          1 Reply Last reply Reply Quote 1
          • A
            astrosofista @Alan Kilborn
            last edited by Jan 24, 2021, 8:43 PM

            @Alan-Kilborn

            Yes, my bad, ${10} is the thing.

            1 Reply Last reply Reply Quote 2
            • P
              PeterJones @Gergely Apró
              last edited by Jan 24, 2021, 9:33 PM

              @Gergely-Apró ,

              The answers you have received are good.

              If you would like more documentation on this, the official Notepad++ docs talk about the substitution expressions here .

              Notepad++ uses what’s known as the “Boost engine” (currently v1.70) for handling the regular expressions, and that has its substitution documentation here

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