Files
30-seconds-of-code/snippets/removeNonASCII.md
Isabelle Viktoria Maciohsek 27c168ce55 Bake date into snippets
2021-06-13 13:55:00 +03:00

444 B

title, tags, firstSeen, lastUpdated
title tags firstSeen lastUpdated
removeNonASCII string,regexp,intermediate 2018-01-26T14:00:54+02:00 2020-10-22T20:24:30+03:00

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'