How to Clean Up Messy Pasted Text from Word and PDFs
Pasting from Word or a PDF often brings along non-breaking spaces, zero-width characters, smart quotes, and em-dashes encoded three different ways.
Fixes
- Run Clean whitespace to collapse multiple spaces and drop empty lines
- Normalize quotes: replace
"" ''with" ' - Replace
U+00A0(non-breaking space) with a regular space - Strip zero-width characters:
/[\u200B-\u200D\uFEFF]/g