I am designing a regular expression tester in HTML and JavaScript. The user will enter a regex, a string, and choose the function they want to test with (e.g. search, match,
Use the JavaScript RegExp object constructor.
var re = new RegExp("\\w+"); re.test("hello");
You can pass flags as a second string argument to the constructor. See the documentation for details.