Skip to content

⬅️ Back to Table of Contents

📄 escapeRegExp

📊 Analysis Summary

Metric Count
🔧 Functions 1
📊 Variables & Constants 1

📚 Table of Contents

🛠️ File Location:

📂 packages/eslint-plugin/src/util/escapeRegExp.ts

Variables & Constants

Name Type Kind Value Exported
reRegExpChar RegExp const /[\\^$.*+?()[\]{}\|]/g

Functions

escapeRegExp(string: string): string

Parameters:

  • string string

Returns: string

Calls:

  • reHasRegExpChar.test
  • string.replaceAll
Code
export function escapeRegExp(string = ''): string {
  return string && reHasRegExpChar.test(string)
    ? string.replaceAll(reRegExpChar, '\\$&')
    : string;
}

Generated by Syntax Scribe