escapeRegExp

Modified on Mon, 31 Jul 2023

Description

Escape the RegExp special characters ('^', '$', '\', '.', '*', '+', '?', '(', ')', '[', ']', '{', '}', and '|') in string

Syntax

escapeRegExp(text)

Parameters

Input ParameterTypeDescription
textstringThe string to escape.

Return value

Type
string

Sample

ExampleResultDescription
escapeRegExp('[A-Z]')'\[A-Z\]'Escape regular expression special characters

To view all the String functions, click here.

See Also