removeNonASCII

Removes non-printable ASCII characters.

  • Use String.prototype.replace() with a regular expression to remove non-printable ASCII characters.
const removeNonASCII = str => str.replace(/[^\x20-\x7E]/g, '');
removeNonASCII('äÄçÇéÉêlorem-ipsumöÖÐþúÚ'); // 'lorem-ipsum'