JS RegExp Objects
The RegExp constructor builds a pattern from a string. String escaping and pattern escaping are separate steps.
Where to run this
This example uses the JavaScript console playground. Select Run to execute it; the example does not run on this lesson page.
A practical example
const digits = new RegExp("^\\d{3}$");
console.log(digits.test("204"));
What happens
The three-digit string matches.