When defining a regular expression, you need to start with a forward slash. You indicate the end of the regex also with a /. After which, you define your parameters (eg. g, i).
const reg = /password/g;
If you are wanting to make use of a character class, you need to escape literal strings using a backslash.
const reg = /string\d/gi;
The above will be interpreted in the following way:
/ Opens a regular expression
string is interpreted as literally “string”
\ escapes literal strings
b. d is interpreted as any numeric digit
/ indicates the end of the expression
g is a flag that indicates the declared expression is to be used globally
i is a flag that indicates the declared expression is case insensitive.