Sublime Forum

Regex - match a particular line

#1

hello, suppose I want to match line 64 on text, how can I do this with regex?

0 Likes

#2
\A(?:^.*$\n){63}\K^.*$
0 Likes

#3

not working

0 Likes

#4

lies, it matches the 64th line for me:

1 Like

#5

you search line number 63 and you find line number 64… :slightly_smiling:
try to find line number 3 with the same regex

0 Likes

#6

What does this have to do with anything? You specifically asked to match line 64 and that’s what it does.

That won’t work because the regex is set to match line 64, not line 3. If you want to match line 3, change the 63 to a 2 instead. A little experimentation will show you that the {63} part of the regex is saying that the previous part needs to match exactly 63 times, and then what follows matches the rest. Thus the number you use always has to be one less than the line you want to match.

1 Like

#7

I apologize. Works great here in sublime_text.

I also use GrepWin to modify more then 1000 files, and it is not working in this editor. So, I will use sublime to modify all 1000 files at once.

thank you

0 Likes

#8

I find another solution on internet. Suppose I want to select and modify the line 4

Find:
\A((?:.*\R){3}).*((?s:.*))\z

Replace with:
$1New Line$2

0 Likes