问题描述
我正在尝试制作一个 API,该 API 从带有 https://github.com/chalk/ansi-regex 的请求正文中删除 ANSI 转义序列。这是快速路线:
const pattern = [
'[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:[a-zA-Z\\d]*(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)','(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))'
].join('|');
let ansiRegex = new RegExp(pattern,'g'); // This code is the main part of chalk/ansi-regex
app.post("/unesc",(req,res) => res.send(req.body.replace(ansiRegex,"")))
这在 99% 的情况下都有效,但如果我使用 neofetch
来执行,则会出现字符串 99D
:
这里也是作为文本文件的 Neofetch 直接输出:https://gofile.io/d/eShH4X
这是某种非标准的转义序列还是 ansi-regex 错误?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)