RegExp.escape()
Newly available since 2025-05-01
The RegExp.escape()
static method takes a string and replaces any characters that are potentially special characters of a regular expression with equivalent escape sequences. For example, RegExp.escape("[abc]")
returns "\\[abc\\]"
.
Learn more
Specifications
- RegExp.escape, from TC39 (Ecma International).
Browser support
- Chrome 136 Released on 2025-04-29
- Chrome Android 136 Released on 2025-04-29
- Edge 136 Released on 2025-05-01
- Firefox 134 Released on 2025-01-07
- Firefox for Android 134 Released on 2025-01-07
- Safari 18.2 Released on 2024-12-11
- Safari on iOS 18.2 Released on 2024-12-11
Usage (according to Chrome Platform Status)
~0.639% of page loads. More data at chromestatus.
View as JSON | Edit this feature | Report an issue | Web-features entry: source, dist