• Escapes a regular expression given as string by escaping all special regular expression characters.

    Parameters

    • text: string

      The text to escape

    • allowTokens: boolean = false

      Whether to allow and keep unescaped tokens like \s, \t, or \n

    Returns string

    The escaped text