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 ๐Ÿ‘‡
developer.mozilla.org/en-US/do

0

If you have a fediverse account, you can quote this note from your own instance. Search https://mastodon.social/users/mdn/statuses/116102372342711050 on your instance and quote it. (Note that quoting is not supported in Mastodon.)