Hello @jim-erlich and All,
Sorry for being late ! So, here are, below, some explanations about my regex S/R :
SEARCH (?-s)^.+#\x20?(\d+)\R(?=.+#\x20?\1)
REPLACE Leave EMPTY
First, the (?-s) in-line modifier ensures that any further . regex symbol corresponds to a single standard character, only and not to a line-break char !
So, the next part ^.+#\x20? searches, from beginning of line ( ^ ), any non-null range of characters ( .+ ), followed by the # symbol and an optional space char (\x20?)
Then, it looks for a non-null range of digits ( \d+ ), followed by line-break character(s)
So, the regex engine looks for an entire line ( digits after the # are stored as group 1 as embedded in parentheses ) but ONLY IF the next line ends with the same number !
This condition can be expressed with a look-ahead structure (?=......) which are rather a user assertion in the same way that, for instance, the $ symbol is a system assertion, looking for the zero length assertion “end of line” !
So current line must be followed with the regex .+#\x20?\1, which represents, again, a non-null range of standard characters followed with a # and possibly a space char and finally the group 1 ( \1 ) which is the ending number of the current line
Note that the ^ assertion for the second line, in the look-ahead structure, is useless as the range (.+) comes next the line-break char(s) \R, anyway !
As the replacement zone is empty, the current line, with its line-break, is just deleted
For a quick oversight about regular expressions, see the N++ documentation, below :
https://npp-user-manual.org/docs/searching/#regular-expressions
See also the main links regarding the Boost regex library, used by the regex N++ engine :
https://www.boost.org/doc/libs/1_70_0/libs/regex/doc/html/boost_regex/syntax/perl_syntax.html
Finally, see this FAQ topic about regular expressions :
https://community.notepad-plus-plus.org/topic/15765/faq-desk-where-to-find-regex-documentation
Best Regards,
guy038