@jiminp/tooltool
    Preparing search index...

    Function escapeRegExp

    • Escapes regex metacharacters for a literal pattern outside character classes.

      Parameters

      • s: string

        String to escape.

      Returns string

      Regex source matching s literally when used as a standalone pattern.

      Suitable for the RegExp constructor, not for generating JavaScript regex literals. Does not escape character-class punctuation such as -, or prevent a leading digit from extending an adjacent escape. Native RegExp.escape() handles those embedding hazards as well.

      Use native RegExp.escape() when available.

      new RegExp(escapeRegExp('example.com')).test('example.com');   // true
      new RegExp(escapeRegExp('example.com')).test('exampleXcom'); // false