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.*\Ror(?ms)(.*\R){26}\K.*\RIt 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
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login