Skip to content

ProtoString escapeRegExp Method

Seth Clydesdale edited this page Jun 8, 2015 · 1 revision

<< Back to Miscellaneous Methods

Example

Escaping regexp characters.

'Would you like ${food}?'.escapeRegExp(); // returns 'Would you like \$\{food\}\?'

Description

The escapeRegExp method escapes special characters used in regular expressions. This can be used to clean a string before inserting it into a regular expression object.

Syntax

String.escapeRegExp();
Clone this wiki locally