A regular expression literal writes a pattern directly in JavaScript source: enclose the pattern in slashes and put any flags after the closing slash. Use one when the expression is known at development time; use the RegExp constructor to build one at runtime. section 10.7
A literal with a flag
const re = /test/i; The i flag makes matching case-insensitive. The same expression can be created with new RegExp("test", "i").
Recognize the literal and its pattern by checking:
- The slash delimiters, as in /test/. section 10.8
- Flags after the closing slash, as in /test/g. section 10.8
- Pattern syntax inside the slashes, such as character sets, quantifiers, groups, and backreferences. section 10.8

