JAVASCRIPT   9

strip.js

Guest on 10th October 2021 06:41:16 AM

  1. 'use strict';
  2.  
  3. module.exports = str => {
  4.   const pattern = [
  5.     '[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:[a-zA-Z\\d]*(?:;[a-zA-Z\\d]*)*)?\\u0007)',
  6.     '(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PRZcf-ntqry=><~]))'
  7.   ].join('|');
  8.  
  9.   const RGX = new RegExp(pattern, 'g');
  10.   return typeof str === 'string' ? str.replace(RGX, '') : str;
  11. };

Raw Paste


Login or Register to edit or fork this paste. It's free.