Build a regex dynamically from strings.
Section: JavaScript Regex APIs
RegExp constructor
javascript
javascript
new RegExp("^" + prefix + "\\d+$", "i")Explanation
Useful when the pattern is assembled at runtime.
Learn the surrounding workflow
Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.
Related commands
Same sheet · prioritizing JavaScript Regex APIs