Safely embed user input in regex patterns π
RegExp.escape() escapes regex syntax characters in a string, so you can use user-provided text as a literal pattern.
Prevents unexpected regex behavior and security issues when dynamically creating RegExp patterns.
Learn more here π
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/escape
MDN Web Docs
@mdn@mastodon.social
The official MDN Web Docs account. We deliver the best web docs around. Visit β https://mdn.dev Contribute β https://mdn.dev/community
mastodon.social
MDN Web Docs
@mdn@mastodon.social
The official MDN Web Docs account. We deliver the best web docs around. Visit β https://mdn.dev Contribute β https://mdn.dev/community
mastodon.social
@mdn@mastodon.social
Β·
Feb 20, 2026
4
0
1
Loading comments...