S
S
Senseich2020-11-13 01:14:16
Regular Expressions
Senseich, 2020-11-13 01:14:16

How to number lines in a text file?

Hi all! Please help with line numbering in a regular txt file. I believe that this is done using regular expressions, but I myself can not "finish" how?

There is such a file, it contains lists that I need to turn into numbered arrays, i.e.:

text1, text1, text1
text2, text2, text2 It is

necessary to add at the beginning and at the end to var Arr_нумерация = [ ]end up like this:

var Arr_1 = [text1, text1, text1]
var Arr_2 = [text2, text2, text2]

I can add characters, but here's how to do auto numbering, please help.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
dodo512, 2020-11-13
@dodo512

Find: [^\r\n]+
Replace with: var Arr_ = [$0]
Then go to the first line of text and put the cursor right after var Arr_.
Next Alt+C or menu Edit >> Column Generator.
Set start number and numbering step.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question