简中文档

no-control-regex

NOTE: this rule is part of the recommended rule set.
Enable full set in deno.json:
{
  "lint": {
    "rules": {
      "tags": ["recommended"]
    }
  }
}
Enable full set using the Deno CLI:
deno lint --rules-tags=recommended
This rule can be explictly included to or excluded from the rules present in the current tag by adding it to the include or exclude array in deno.json:
{
  "lint": {
    "rules": {
      "include": ["no-control-regex"],
      "exclude": ["no-control-regex"]
    }
  }
}

不允许在正则表达式中使用 ASCII 控制字符。

控制字符是位于 ASCII 范围内的不可见字符,范围为 0-31。在正则表达式中使用这些字符是不常见的,通常是正则表达式中的错误。

无效示例:

// 使用 ASCII (31) 回车符 (十六进制 x0d) 的例子
const pattern1 = /\x0d/;
const pattern2 = /\u000d/;
const pattern3 = new RegExp("\\x0d");
const pattern4 = new RegExp("\\u000d");

有效示例:

// 使用 ASCII (32) 空格 (十六进制 x20) 的例子
const pattern1 = /\x20/;
const pattern2 = /\u0020/;
const pattern3 = new RegExp("\\x20");
const pattern4 = new RegExp("\\u0020");

你找到了你需要的东西吗?

编辑此页面
隐私政策