Hello, Claudia, Justin and Scott,
Justin, in addition to the Python script and the native N++ column editor feature, here is a regex S/R equivalent :-))
So, let’s suppose that we start with the original text, below :
BEGINNING
This is a test
A line with 25 characters
an another try
+
a COMPLETE line of 34 characters_1
END
Open the Replace dialog
In the Find what : field, type :
(?-s)^(?!.{34}( |1))(.+)|^.{34}\K +
In the Replace with : field, type :
?2\2 1 , with 34 SPACES, between \2 and the digit 1, that should be ADDED
Select the Regular expression search mode
Click, TWICE, on the Replace All button ( IMPORTANT )
You should obtain the modified text, below :
BEGINNING 1
This is a test 1
A line with 25 characters 1
an another try 1
+ 1
a COMPLETE line of 34 characters_11
END 1
NOTES :
The (?-s) syntax ensures that the dot ( . ) will stand for standard characters, only !
The ^ is the assertion beginning of line, which must be verified
The negative look-ahead ( (?!.{34}( |1)) ) verifies if the condition NO space NOR the 1 digit, at position 35, is true. This case occurs, ONLY, on the original text, before any S/R
So, the regex catches, first, all the standard characters ( .+ ), of any non-empty line, stored in group 2
In replacement, as group 2 exists, it rewrites the current line, then adds a minimum of 34 spaces and the final digit 1
When you click a second time, on the Replace all button, the left part of the alternative cannot be achieved, as the look-ahead condition is, this time, false
So, the regex engine tries to match the right part of the alternative ( ^.{34}\K + )
The first part ( ^.{34} ) select the first 34 characters of each line
Due to \K syntax, this range is forgotten and the regex engine, now, matches any consecutive non-null range of space characters ( + ), from the 35th position, included
In replacement, as the group 2 is not used any more and that the conditional replacement, ?2... , do not have an ELSE part, these space characters are simply deleted !
REMARKS :
The nice thing is that you may add, as many spaces, as you want, after the 34 first spaces, in the replacement field !
And, any additional click, after the second one, on the Replace all button, does not match anything else :-))
Cheers,
guy038