Community

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

    RegEx set number of spaces bevore captured group in replace

    Help wanted · · · – – – · · ·
    3
    5
    119
    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.
    • black_cat
      black_cat last edited by

      Hi everyone,
      Hi to the RegEx Masters, ;)

      I often have long text files, that are written in a Pseudo-Code, those files are basically
      instructiosn how to print something, they also have “blanks bevor starts” now some of them have 3 othres 10 or another number.

      now when I’m chekcing theese files in notepad++, which is greate because of some custom syntax-highlighing i worte, i have a need to see the positinos of the elements on there true posistions. In order to get this i usa the find and replace function with regex:

      ef8962e2-d568-47e6-96ea-cf98be3a67df-grafik.png

      b2c9ed78-1464-43ac-b04e-bc43fd74f876-grafik.png

      this works but is somewhat anoying.

      Now to the Question:

      is there a way to set the number spaces liek [space]{10}\1

      a3fd1e10-affc-4390-bc45-1952e7307633-grafik.png

      this does not work:

      19352a38-e294-41ff-9b58-1ab178c7903d-grafik.png

      What am I missing? Or is this a limitation of RegEx , or our RegEx flavour?

      PeterJones Neil Schipper 2 Replies Last reply Reply Quote 0
      • PeterJones
        PeterJones @black_cat last edited by

        @black_cat said in RegEx set number of spaces bevore captured group in replace:

        Or is this a limitation of RegEx , or our RegEx flavour?

        I have never seen a flavor of regex that has quantifiers in the replacement section. That might be nice, but I haven’t seen it before. Sorry.

        1 Reply Last reply Reply Quote 1
        • Neil Schipper
          Neil Schipper @black_cat last edited by

          @black_cat said in RegEx set number of spaces bevore captured group in replace:

          is there a way to set the number spaces liek [space]{10}\1

          What the other guy said.

          But also be aware that you can use the numeric codes for spaces, as in \x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\1 which makes the expression longer (and so in a way uglier) but also prevents having to look at a sea of white space which is cumbersome to determine length of.

          1 Reply Last reply Reply Quote 2
          • black_cat
            black_cat last edited by

            Thanks to both of you, know that I know that it’s not just my own “not knowing”
            i can stop thinking about it so much whenever i work with this.

            @Neil-Schipper if I have to use a larger number of blanks i usually mark them in notepad++ in an empty new tab and count the selection:

            74d9db68-e2dd-4378-8641-2f0cc2678b8d-grafik.png

            It just would have been niche to sovle this with a RegEx quantifier, but if it isn’t there it isn’t there. ^-^

            Neil Schipper 1 Reply Last reply Reply Quote 0
            • Neil Schipper
              Neil Schipper @black_cat last edited by

              @black_cat Do you know about Edit -> Colum Editor? If your files are well behaved, it can be used to insert a rectangle (full of blanks) to left of existing text.

              Also, do you know about recording macros? You can record a macro that does, for ex.

              <Home><3 spaces><Home><Down>

              and then run it on the whole file when you want to prepend 3 spaces. You can save it as a named macro. You can make a separate macro for each width you routinely need.

              1 Reply Last reply Reply Quote 1
              • First post
                Last post
              Copyright © 2014 NodeBB Forums | Contributors