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