• Login
Community
  • Login

Replace help

Scheduled Pinned Locked Moved General Discussion
18 Posts 5 Posters 783 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.
  • E
    Ekopalypse
    last edited by Ekopalypse Mar 5, 2021, 3:24 PM Mar 5, 2021, 3:23 PM

    @Alan-Kilborn

    you are right. I’m one off.
    So the correct regex would be (?<=^2.{11}998.{35}).{4}

    I am still confused by the fact that the position as shown in the statusbar no longer starts at 0.

    @Gert-Beliën
    Could it be that we both had a off by one issue? :-D

    A 1 Reply Last reply Mar 5, 2021, 3:31 PM Reply Quote 1
    • G
      Gert Beliën
      last edited by Mar 5, 2021, 3:24 PM

      I needed indeed .{35} to make it work but that I found out myself -:)

      1 Reply Last reply Reply Quote 4
      • E
        Ekopalypse
        last edited by Mar 5, 2021, 3:30 PM

        @Gert-Beliën

        Great :-)

        A short explanation what the regex does,
        it is using a lookbehind (?<=...) for the condition to match .{4}

        ^ means start of line
        2
        .{11} any character but 11 times
        998
        .{35} any character but 35 times

        So basically it means the line has to start with 2, followed by 11 characters, followed by 998, followed by 35 characters and then match the next 4 characters.
        Lookbehind can only be used with a fixed length term to search, which was the case here. :-)

        1 Reply Last reply Reply Quote 1
        • A
          Alan Kilborn @Ekopalypse
          last edited by Mar 5, 2021, 3:31 PM

          @Ekopalypse said in Replace help:

          I am still confused by the fact that the position as shown in the statusbar no longer starts at 0.

          You mean the Pos: thing?
          It’s relatively new, right?
          But I believe it has always been “one based”, never “zero based”.

          (I wish it was zero-based, as that would help when writing my PythonScripts – Scintilla always deals with zero-based positions)

          E 1 Reply Last reply Mar 5, 2021, 3:32 PM Reply Quote 1
          • E
            Ekopalypse @Alan Kilborn
            last edited by Mar 5, 2021, 3:32 PM

            @Alan-Kilborn said in Replace help:

            But I believe it has always been “one based”, never “zero based”.

            Really, I’m getting old and confused :-D

            P E 2 Replies Last reply Mar 5, 2021, 3:37 PM Reply Quote 1
            • P
              PeterJones @Ekopalypse
              last edited by Mar 5, 2021, 3:37 PM

              @Ekopalypse said in Replace help:

              @Alan-Kilborn said in Replace help:

              But I believe it has always been “one based”, never “zero based”.

              Really, I’m getting old and confused :-D

              I’ve always just added a line like

              123456789x123456789x123456789x123456789x123456789x123456789x123456789x123456789x
              

              when I’m answering positional-based requests, That method works in any version of Notepad++ and doesn’t make me think about 0-based vs 1-based. :-)

              A 1 Reply Last reply Mar 5, 2021, 3:40 PM Reply Quote 2
              • A
                Alan Kilborn @PeterJones
                last edited by Alan Kilborn Mar 5, 2021, 3:42 PM Mar 5, 2021, 3:40 PM

                @PeterJones said in Replace help:

                I’ve always just added a line like

                Ha! I did that too!:

                bf679ad0-beaa-4454-ac82-e2b7d7e5dd4c-image.png

                (RegexBuddy pictured)

                This, in N++ is even handier, but I can’t find where I’ve put it quickly enough sometimes:

                123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-
                         10        20        30        40        50        60        70        80        90       100
                
                P 1 Reply Last reply Mar 5, 2021, 3:44 PM Reply Quote 1
                • E
                  Ekopalypse
                  last edited by Mar 5, 2021, 3:42 PM

                  @Alan-Kilborn @PeterJones

                  Lazy as I’m I looked at the statusbar until I saw 50(thinking it must be 51 because scintilla start from 0) and then selected the dots - which was obviously wrong.

                  c9e47f02-981c-4158-86db-5ca8f48f6383-image.png

                  1 Reply Last reply Reply Quote 2
                  • P
                    PeterJones @Alan Kilborn
                    last edited by PeterJones Mar 5, 2021, 3:44 PM Mar 5, 2021, 3:44 PM

                    @Alan-Kilborn said in Replace help:

                    This, in N++ is even handier, but I can’t find where I’ve put it quickly

                    I find it’s faster to re-create than to store in some useful copy-and-paste location. Typing the 10 characters, then duplicating 8+ times, is pretty fast (and almost in my muscle memory now).

                    I suppose we could create macros to insert those. :-)

                    1 Reply Last reply Reply Quote 1
                    • E
                      Ekopalypse
                      last edited by Mar 5, 2021, 3:47 PM

                      Yeah, we could. Maybe I should have written a python script to do it :-)

                      And now the question, why were the first dots correct? I counted them. :-D

                      A 1 Reply Last reply Mar 5, 2021, 7:29 PM Reply Quote 1
                      • A
                        astrosofista @Ekopalypse
                        last edited by Mar 5, 2021, 7:29 PM

                        @Ekopalypse, @Alan-Kilborn, @PeterJones

                        Actually there is a Python script for it. In my configuration is at

                        “D:\Applications\npp.7.9.1.portable.x64\plugins\PythonScript\scripts\Samples\InsertRuler.py ”

                        For learning purposes I replicated most of it in AutoHotkey, but I rarely use any of both.

                        Take care and have fun!

                        1 Reply Last reply Reply Quote 2
                        • E
                          Ekopalypse @Ekopalypse
                          last edited by Ekopalypse Mar 5, 2021, 7:31 PM Mar 5, 2021, 7:31 PM

                          @Ekopalypse said in Replace help:

                          Really, I’m getting old and confused :-D

                          once again …

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