How to add the numbers in sequence to specific text;
-
Hi i have a file like this:
358 293 commit; 866 511 commit; 58 767 commit; 562 644 commit; 163 569 commit; 414 305 commit;i am wanted to get the output like this;
358 293 commit;1 866 511 commit;2 58 767 commit;3 562 644 commit;4 163 569 commit;5 414 305 commit;6Like i am wanted to add the numbers in sequence; how can i do this with notepad++
-
This can be accomplished in a very similar (and easier) way as showed in my reply to your other question.
Ref.:
https://community.notepad-plus-plus.org/post/51862So, select the first semi colon
;, then apply Ekopalypse’s Python script to get all of them. Press the Right Arrow, open the Column Editor and enter data as needed. That’s all.BR
-
Hello, @garbage-gold, @astrosofista and All,
Of course, regexes cannot perform, generally, mathematical operations, but we can cheat a bit !
-
First, open the Replace dialog
-
SEARCH
(?<=\d)\R( or(?<=\w)\Rif your text contains words instead of numbers ) -
REPLACE
\t -
If necessary, tick the
Wrap aroundoption -
Select the
Regular expressionsearch mode -
Click on the
Replace Allbutton
-
=> Your text in changed as below, with a TAB char between each word :
358 293 commit; 866 511 commit; 58 767 commit; 562 644 commit; 163 569 commit; 414 305 commit;Notes
-
This regex S/R looks for any EOL character(s), which is/are preceded with a number (
(?<=\d)) ( or a word if(?<=\w)) -
And replaces it with a tabulation character (
\t)
-
Now, put the caret at the end of the first line
-
Open the column editor (
Alt + C)-
Select
Number to Insert -
Type in
1in all the zones -
If necessary, tick the
Leading zerosoption -
Click on the
OKbutton
-
-
Remove additional numbers on possible empty lines, at the end of the list
You should get :
358 293 commit;1 866 511 commit;2 58 767 commit;3 562 644 commit;4 163 569 commit;5 414 305 commit;6
-
Finally, perform the last regex S/R, below :
-
SEARCH
\t -
REPLACE
\r\n( or\nonly for Unix files )
-
Here is your expected text :
358 293 commit;1 866 511 commit;2 58 767 commit;3 562 644 commit;4 163 569 commit;5 414 305 commit;6Et voilà !
Best Regards,
guy038
-