Read regular expression from String

I want the user to input a regular expression, which is then used.

I’m using following at the moment.

var filterEx = new RegExp(filterTxt.text.split("/")[1], filterTxt.text.split("/")[2]);

filterTxt is a textbox, when traceing the pattern is seemingly correct, but i.e.:

/\d+/ does match several numbers, but not all like it doesnt match 10 or 11.
/\d\d/ does match 10 or 11 but I’m not sure if it matches any 2 digit number.
/10/ does match 10 too.

So I hope there is a better way from string to regex.