Removes non-printable ASCII characters.
Use a regular expression to remove non-printable ASCII characters.
代码片段
const removeNonASCII = str => str.replace(/[^\x20-\x7E]/g, '');
使用样例
removeNonASCII('äÄçÇéÉêlorem-ipsumöÖÐþúÚ'); // 'lorem-ipsum'
Removes non-printable ASCII characters.
Use a regular expression to remove non-printable ASCII characters.
const removeNonASCII = str => str.replace(/[^\x20-\x7E]/g, '');
removeNonASCII('äÄçÇéÉêlorem-ipsumöÖÐþúÚ'); // 'lorem-ipsum'