Function escapeRegExp

  • Escapes the RegExp special characters "^", "$", "", ".", "*", "+", "?", "(", ")", "[", "]", "{", "}", and "|" in string.

    Parameters

    • string: string

      The string to escape.

    Returns string

    string Returns the escaped string.

    Since

    5.12.0

    See

    [[escape]], [[escapeRegExp]], [[unescape]]

    Example

    escapeRegExp('[lodash](https://lodash.com/)')
    // => '\[lodash\]\(https://lodash\.com/\)'