Replace help
-
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 -
I needed indeed .{35} to make it work but that I found out myself -:)
-
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 timesSo 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. :-) -
@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)
-
@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
-
@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. :-)
-
@PeterJones said in Replace help:
I’ve always just added a line like
Ha! I did that too!:
(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
-
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.
-
@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. :-)
-
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
-
@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!
-