Blank a page | ||
---|---|---|
Creator: | Alan Moore | |
Code location: | stackoverflow.com | |
What it does: | Blanks a whole page of test | |
Complexity: | Advanced | |
Known working on: | 20130104214515 |
Blank a page is a bit of regex that will delete the entirety of a page's content.
It is typically used with the replace.py script.
Code
Edit
python replace.py -regex "^(.+)(?:\n|\r\n?)((?:(?:\n|\r\n?).+)+)" ""
Explanation
Edit
This regex will start at each new line (hence the carat), match all the text afterward, continuing through each new line until the entire page has been matched.
Known limitations
Edit
It gets rid of everything on a page, so it should be considered the "nuclear bomb" of regex replacements. Though it can be adapted to more subtle use, this is what you bring out only when you absolutely want to blank pages.
It has not been tested on pages that contain lines that begin with a space (generally a mistaken and unexpected editing condition), but it should work even on these lines.