Regex: Select only the line 27 (mark a particular line)
-
hi, how can I select a particular line with regex, for ex. line 27 on text document?
-
You could use the technique presented here:
https://notepad-plus-plus.org/community/topic/12291/character-position/4 -
The formula below works in sublime text editor. But I don’t know why is not working in notepad++. Maybe guy038 will find the solution for notepad++.
\A(?:^.*$\n){3}\K^.*$
This regex will select line 4 from text.So If I want to select line 6, I will put {5}
Anyway, can anyone make this regex formula to work also in notepad++ ?
-
Using @guy038’s technique presented in the link pointed to by @scott-sumner e.g. select line 27 in text document:
(?-s)(.*\R){26}\K.*\R
-
SUPER ! Thanks.
\R cause some problem at replace, so is much better \r at final
(?-s)(.*\R){2}\K.*\r
-
some problem
What exactly?
-
there is one bug in this formula
(?-s)(.*\R){26}\K.*\R
or(?ms)(.*\R){26}\K.*\R
It is not unique. It will selects all the multiple of line I choose. (If I press “Replace All” with something)
in this case, it selects the 27 row, but also selects 54, 81, 108…etc
-
-
hello MapJe27. I am sorry, I cannot find an answer in that post. There, I see a regex that find a line between columns. But not an unique line, that can be use for Replace All in many documents.
maybe you can help me a little bit.
-
Notes :
Always locate your cursor at the beginning of your file, first@Vasile-Caraus said in Regex: Double your words:
If I want to replace one single line in many files
It would been a lot easier/faster if you had shared this information from the start in this topic!
I can’t say it’s not possible with regular expressions, I just don’t know how. I’d use a script with one of the script plugins (PythonScript, LuaScript).
-
Hi Vasile Caraus,
Just see my solution, below, in topic about replacing by multiple values of a same line :
https://notepad-plus-plus.org/community/topic/12341/regex-double-your-words/9
Cheers,
guy038