Hongmu Notes

🎯 Keep lines with no more than N characters

Filter by character count line by line, retaining only lines whose length does not exceed N.

Instructions for use

  • Fill in the upper limit of the number of characters (keep it if it does not exceed it) and click "Start Filtering"
  • Lines whose length is exactly equal to the upper limit are retained; empty lines are also retained
  • If you need to keep long lines, please use "Only keep lines longer than N characters"

What can this tool do?

  • Filter by the number of characters line by line, retaining lines whose length does not exceed N
  • Lines whose length is exactly equal to N will be retained (no more than that)
  • The content of the row is not changed, only the entire row is retained or deleted.
  • The results can be copied and exported as TXT, and the original text will not be altered.

Actual measurement effect

Input (keep lines of no more than 3 characters)output
ab
abc
abcd
abcde
ab
abc
(blank line)(blank lines are preserved)

"Not more than" includes equal to: lines with a length of exactly 3 will be retained, and lines with a length of 4 and above will be removed.

Usage tips

  • To clean up truncated very long lines, use this page; to clean up noisy lines that are too short, use "Keep only lines longer than N characters"
  • The length of an empty line is 0, and it will be retained if N is not less than 0.
  • If you need to filter by keywords, please use the "Text Line Preservation Filter" tool.

All keywords and tutorials 12

❓ FAQ

which rows does it retain
Determine the number of characters line by line: lines with a length "not exceeding" N are retained (including lines with a length exactly equal to N), and lines exceeding N are deleted entirely; the line content itself is not modified in any way.
What is the difference between "only keep lines longer than N characters"
The two are complementary: this page retains the short one (≤ N), and that tool retains the long one (> N). Use this page to clean truncated long lines, and use that to clean short noisy lines.
What will happen if N is filled in with 0?
Blank lines will be retained (the length is 0 or no more than 0), and all other lines will be deleted; if the original text has only one blank line, the result box will look empty (the single blank line will be an empty string after concatenation).
What happens if N is not a number?
All rows will be retained. The original implementation uses "length greater than parameter" to judge. When the parameter is not a number, the comparison result is always false, so all lines are retained (a prompt will be given on the page).
Will the data be uploaded?
No. Filtering is done locally in the browser, and input and results do not pass through the server or be written to local storage.