javascript - 为什么在 neofetch 上使用 npm 包 ansi-regex 时不过滤“99D”?
问题描述
我正在尝试制作一个 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 是错误的?
解决方案
推荐阅读
- python - 如何将列标题复制到熊猫中的其他列
- slack - 使用 Slack API 为用户订阅线程
- go - 在Android中加载图像作为静态服务器
- json - 为非重复字段指定的数组,我可以将 JSON 格式“{a:[1,2,3]}”加载到 BQ 中吗
- serialization - Sitecore 10 Helixbase 序列化错误 - 您的模块依赖项中存在依赖项循环
- xamarin.forms - Xamarin Forms 访问自定义 p12 文件?
- python - Openpyxl:如何比较两个工作表中的单元格值
- regex - Bash 使用正则表达式将 API 调用的结果添加到日志文件
- c++ - 我找不到导致无限循环的错误
- powershell - 如何在 Azure 函数中运行 power shell 脚本