需求
下面的代码我想匹配中间 try 开头 // eslint-disable-line 结束,并且中间有 worker_threads 关键词的部分
var WorkerClass = null;
try {
    var WorkerThreads =
        typeof module !== 'undefined' && typeof module.require === 'function' && module.require('worker_threads') ||
        typeof __non_webpack_require__ === 'function' && __non_webpack_require__('worker_threads') ||
        typeof require === 'function' && require('worker_threads');
    WorkerClass = WorkerThreads.Worker;
} catch(e) {} // eslint-disable-line
function decodeBase64$1(base64, enableUnicode) {
    return Buffer.from(base64, 'base64').toString(enableUnicode ? 'utf16' : 'utf8');
}
正则
下面的代码是 Github copilot 写的,恐怖如斯啊
try\s*{[\s\S]*?worker_threads[\s\S]*?}[\s\S]*?// eslint-disable-line
这个是我写的
^try [\s\S]*worker_threads[\s\S]* eslint-disable-line