Community
    • Login

    Replace help

    Scheduled Pinned Locked Moved General Discussion
    18 Posts 5 Posters 658 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.
    • Gert BeliënG
      Gert Beliën
      last edited by

      So that string I have to place in the search.
      What do a place in the replace section?
      maybe stupid question but I’m new to this, so I apologise

      EkopalypseE 1 Reply Last reply Reply Quote 0
      • EkopalypseE
        Ekopalypse @Gert Beliën
        last edited by Ekopalypse

        @Gert-Beliën

        Yes, replace with 1250 and make sure you have checked regular expression search and put your cursor in the very first position of the document or check wrap aronud

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

          @Ekopalypse said in Replace help:

          (?<=^2.{11}998.{34}).{4}

          Is there a one-off problem here?
          I see this matching positions (one-based) 50-53, not 51-54.
          Or maybe it’s me.
          If it IS wrong, let’s see if OP is savvy enough to see the patterns in the expression and correct it himself. :-)

          EDIT: Guess it was me as the OP is happy (see post below). Disregard!!

          1 Reply Last reply Reply Quote 2
          • Gert BeliënG
            Gert Beliën
            last edited by

            @Ekopalypse said in Replace help:

            (?<=^2.{11}998.{34}).{4}

            I don’t understand but hey “It works” :-)
            Thank you very much @Ekopalypse

            1 Reply Last reply Reply Quote 1
            • EkopalypseE
              Ekopalypse
              last edited by Ekopalypse

              @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

              Alan KilbornA 1 Reply Last reply Reply Quote 1
              • Gert BeliënG
                Gert Beliën
                last edited by

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

                1 Reply Last reply Reply Quote 4
                • EkopalypseE
                  Ekopalypse
                  last edited by

                  @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
                  • Alan KilbornA
                    Alan Kilborn @Ekopalypse
                    last edited by

                    @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)

                    EkopalypseE 1 Reply Last reply Reply Quote 1
                    • EkopalypseE
                      Ekopalypse @Alan Kilborn
                      last edited by

                      @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

                      PeterJonesP EkopalypseE 2 Replies Last reply Reply Quote 1
                      • PeterJonesP
                        PeterJones @Ekopalypse
                        last edited by

                        @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. :-)

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

                          @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
                          
                          PeterJonesP 1 Reply Last reply Reply Quote 1
                          • EkopalypseE
                            Ekopalypse
                            last edited by

                            @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
                            • PeterJonesP
                              PeterJones @Alan Kilborn
                              last edited by PeterJones

                              @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
                              • EkopalypseE
                                Ekopalypse
                                last edited by

                                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

                                astrosofistaA 1 Reply Last reply Reply Quote 1
                                • astrosofistaA
                                  astrosofista @Ekopalypse
                                  last edited by

                                  @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
                                  • EkopalypseE
                                    Ekopalypse @Ekopalypse
                                    last edited by Ekopalypse

                                    @Ekopalypse said in Replace help:

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

                                    once again …

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