Regular expression to remove X lines after target line

RegEx

Notepad++ is a great tool, especially when working with files that must be converted from a variety of origins. I recently I received a file that looked like it had followed a route of this nature,

Windows box editor -> Word(?) -> Pandoc -> LaTeX

When cleaning these files up, much work can be saved by looking for sequences in the document that can be easily replaced, or removed, en masse. There was a lot of cruft strewn around the file, and a lot of work was saved by removing blocks of wrapped lines that followed \section and \subsection tags.

This was accomplished via notepad++ by grouping the line including the \subsection and replacing with the capture $1,

^( \\subsection.*\r?\n)(.*\r?\n){2}

Be the first to comment

Leave a Reply

Your email address will not be published.


*