Regex for fast JSON escape for string [closed]

The purpose of this regex is to have a very fast check for strings that do not need escaping while not being much slower than JSON.stringify() in case the input requires escaping. In summary, this regular expression is used to match and handle surrogate pairs correctly in Unicode strings, ensuring proper validation and handling of UTF-16 encoded characters

/[u0000-u001fu0022u005cud800-udfff]|[ud800-udbff](?![udc00-udfff])|(?:[^ud800-udbff]|^)[udc00-udfff]/

the real word usage is:

const strEscapeSequencesRegExp = /[u0000-u001fu0022u005cud800-udfff]|[ud800-udbff](?![udc00-udfff])|(?:[^ud800-udbff]|^)[udc00-udfff]/

/**
 * Fast JSON escape for string
 * @param {string} str
 * @returns {string}
 */
function strEscape (str) {
  if (typeof str !== 'string') {
    throw new TypeError(`Expected input to be of type string, received type ${typeof str} (${str})`)
  }
  // Only use the regular expression for shorter input. The overhead is otherwise too much.
  if (str.length < 5000 && !strEscapeSequencesRegExp.test(str)) {
    return `"${str}"`
  }
  return JSON.stringify(str)
}

I’m trying to optimize it and it seem the first part of the regex always check for the other parts and can be simplified in:

/[u0000-u001fu0022u005cud800-udfff]/

I’m correct? I have miss some test case?

const NEW = /[u0000-u001fu0022u005cud800-udfff]/;
const OLD = /[u0000-u001fu0022u005cud800-udfff]|[ud800-udbff](?![udc00-udfff])|(?:[^ud800-udbff]|^)[udc00-udfff]/;

const STRS = [
    'huaishdPUHAUShduiasuZ9172387AUihausihdu',
    'nrftb"\jiOJIjaiushdnrftb"\KJoa',
    'jiOJIjaiushdnrftb"\KJoanrftb"\',
    'nsiojIOJnu"hu9nasd8"\jiOJIjaiushd"\KJoa',
    'huaishdPUHAUShduiasu6d7nhqmpshejy0fZ9172387AUihausih6d83jb9y0qajusidhnjasnj'.repeat(40),
    'nrftb"\jiOJIjaiushdnrf6d9gmtb"\Kiusu8unrf8ajgshdnrf7tb"\KJoa'.repeat(40),
    'nsiojIOJnu"hu9na7d9\9qjgml1\sd8"\jiOJIjaius"hiushd"\Kd"\KJ'.repeat(40)
];

let allSame = true;
for(const STR of STRS){
  const resOld = OLD.test(STR);
  const resNew = NEW.test(STR);
  if( resOld !== resNew ) {
    allSame = false;
    console.log('Error on: ' + STR, {resOld, resNew}) 
  }
}
if(allSame){
  console.log('the new regex check the same things') 
}