Stripping numbers is the harder half
Adding numbers is a one-line loop. Removing them is what people need after copying a code sample out of a documentation site, a PDF, or the output of cat -n, nl or grep -n, and almost no tool that adds them can.
A regular expression deleting a leading run of digits is dangerous: over a price list, a CSV whose first column is an id, or prose where a sentence starts with a year, it destroys data silently. So the document shape is checked first. A number has to lead or trail at least 60% of non-blank lines, those lines must use the same punctuation, and the numbers must climb by a constant step. If any of that fails nothing is removed, with Strip anyway as an override.
Indentation survives: the smallest gap any numbered line used is measured and only that much removed, so a nested block comes out still nested. It is a heuristic, though. A document where numbers really do appear on half the lines will not be recognised, and a table whose first column is a sequential id will be.
Common problems
- "No line numbers found" on text that clearly has them. An unusual separator. Recognised: full stop, closing round or square bracket, colon, vertical bar, hash, angle bracket, dash, with or without surrounding space or tab, plus plain whitespace on its own.
- The numbers came off but the code lost its indentation. The numbering used spaces rather than a tab and one line had none, which sets the smallest gap for the whole document. Strip a smaller selection.
- Windows line endings. CRLF stays CRLF, both when numbering and when stripping, and a file that ended with a newline still ends with one.
Frequently asked questions
Can it remove numbers it did not add?
Yes. Right-aligned, zero-padded, negative, followed by a full stop, bracket, colon, vertical bar, tab or nothing more than a space, and at the end of the line as well as the start. A number written straight against the text, as in 1foo, is left alone: that is a word beginning with a year far more often than it is a numbered line.
Why did it refuse to strip my numbers?
They did not climb by a constant step, or too few lines carried one. The message above the text boxes says which. That check is the difference between removing line numbers and quietly deleting the first column of your data. Only the settings go in the URL, never your text.
Will it renumber a Markdown or HTML ordered list?
It will number the lines of one, but treat that with care. In Markdown the list marker is syntax, so stripping turns an ordered list into plain paragraphs, and adding a second number produces "1. 1. item". Strip first, then add.
Does it change my line endings?
No. CRLF stays CRLF and LF stays LF, both when numbering and when stripping, and a file that ended with a newline still ends with one. Mixing the two is the one case where a document cannot keep both, and it is normalised to the one that appeared first.