Given:
pad_
pad_
pad_
How would it be possible to use a regular expression to act like a "for loop" to obtain:
pad_1
pad_2
pad_3
I am aware that numbered sequences such as \1
and \2
can be used in replacement expressions to indicate ()
captures in existing text, but can a single replacement expression generate its own replacement values as a numerical sequence? Is there some kind of trick to make this happen besides keeping on-hand a text file with a sequence of numbers that I can copy/paste, or writing a quick application that outputs text using a "for loop"?
CONCLUSION: I get the impression that the regular expression syntax is not a standard uniformly implemented by text editing applications, nor does it include anything that meets the purpose of utilizing match counts in replacement expressions or initiating replacement text sequences. Unfortunately, that means that I would need to use text editors like vim that could do this for purposes unsuited to them, or attempt to find or make application plugins for the text editor or IDE that I would be using. But it would actually be much simpler to compile and run a quick "for loop" that prints the strings for me to copy/paste and which I can reuse by altering in minor ways, or to use awk
which was suggested.
if perl is ok, I guess awk would be ok too:
awk '$0=$0 NR' file
I don't have notepad++, but it is an easy job for vim.
%s/$/0/
This append the 0
to each lineggVG
gCtrl-A
It looks like:
V
for example) the lines you want to append seq:'<,'>s/$/\=line('.')-line("'<")+1
when you press :
the '<,'>
range will be filled automatically