Conversion to RegExp

When non-RegExp values are used in a place where a regular expression is expected, the value is converted to a regular expression with new RegExp(...).

This can have unintended consequences if special characters are not properly escaped.

This is a match because . in a regular expression matches any character. In order to only match a dot character, you would need to escape the input.

Was this page helpful?