textclean
v0.1.0
Published
A robust text cleaning library for JS
Maintainers
Readme
textclean
A multi-language (Python, JavaScript) text cleaning library with CLI support.
Features
- Trim leading/trailing whitespace
- Collapse multiple spaces
- Normalize newlines
- Remove zero-width Unicode chars
- Remove non-breaking spaces
- Preserve emojis
- Preserve language accents
Usage
JavaScript
import { clean } from "textclean";
const text = " Hello World! \u200B ";
const cleaned = clean(text, {
trim: true,
collapseSpaces: true,
});
console.log(cleaned); // "Hello World!"Python
from textclean import clean
text = " Hello World! \u200B "
cleaned = clean(text, options={
"trim": True,
"collapse_spaces": True
})
print(cleaned) # "Hello World!"CLI
# Process a file
textclean input.txt > output.txt
# Pipe from stdin
echo " Hello World! " | textcleanStructure
core/js: JavaScript implementation and CLIcore/python: Python implementation and CLI
AI Assistance Disclaimer
This project was developed with assistance from AI/LLMs (including GitHub Copilot, ChatGPT, and related tools), supervised by humans who occasionally knew what they were doing.
