Marking lines immediatelly after marked lines
-
hello friends, How can I mark 1 line next to the lines containing a specific word?
-
Hello @mortaza-azizi,
Not difficult with regular expressions !
Let’s suppose we would like to mark any line containing the license string, as well as the lines just below each line which contains the license string, in the usual license.txt file, part of any N++ package :
-
Open the license.txt file in Notepad v.7.5.4
-
Open the Mark dialog ( Search > Mark… menu command )
-
Check the Bookmark line, Wrap around and Regular expresion options
-
Check the Match case option, if necessary
-
UN-check the Purge for each search option
-
Type in
(?-s).*license.*, in the Find what: zone -
Click on the Mark All button
-
Type in
(?-s)license.*\R\K.*\R, in the Find what: zone -
Click, a second time, on the Mark All button
Et voilà !
Notes :
-
As usual, the modifier
(?-s)means that any dot character will match a single standard characters, only -
In the first regex, the part
.*license.*matches any line containing the string license -
In the second regex, the part
license.*\Rmatches the remaining of the line, beginning with the string license, with its End of Line chars -
Then, the
\Ksyntax forces the regex engine to forget any previous match -
So, the final regex is, simply,
.*\R, which matches the entire contents of the next line. Note that the\Rsyntax, at the end of the regex, which matches the line-break characters, is needed, when this next line is a true blank line !
Best Regards,
guy038
-
-
Hello @guy038
Thanks for your comprehensive reply to my question.
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