๐Ÿ“š General & Other

Digit Filtering Catches More Than Numbers

keeps lines containing an ASCII digit. On real marketing data it also catches a lot you did not intend.

grep '[0-9]' keeps lines containing an ASCII digit. On real marketing data it also catches a lot you did not intend.

URLs are full of incidental digits

Percent-encoding, port numbers, dates in paths and IDs in query strings all contain digits. Filtering a URL list for numeric content returns nearly all of it, which is not a filter at all.

Non-ASCII numerals

\d in a Unicode-aware engine matches Devanagari, Arabic-Indic and other numeral systems; a literal [0-9] does not. Full-width digits from CJK sources look identical to ASCII ones and match neither unless normalised to NFKC first.

Match position and quantity

If the requirement is "a four-digit year", write [0-9]{4} with boundaries rather than testing for any digit. If it is "purely numeric", anchor the whole line as ^[0-9]+$. The vague version and the precise version return very different sets, and only one of them answers the question.

Try it: Keep Lines With Digits on SeoWolf's Notepad.