removeNonASCII.js 378 B

1234567891011121314
  1. var toString = require('../lang/toString');
  2. /**
  3. * Remove non-printable ASCII chars
  4. */
  5. function removeNonASCII(str){
  6. str = toString(str);
  7. // Matches non-printable ASCII chars -
  8. // http://en.wikipedia.org/wiki/ASCII#ASCII_printable_characters
  9. return str.replace(/[^\x20-\x7E]/g, '');
  10. }
  11. module.exports = removeNonASCII;