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'