in reply to Checking user input on dynamic regular expressions

You shouldn't have to escape anything, which works out well, because the substitution: s|/|\/|gs; is basically a no-op. :) (You'd need an extra backslash in the replacement to make that do what you intended.)

Just test the regex in an eval to make sure it compiles, as suggested earlier. And do not do the following: use re 'eval'; because then you could end up evalling arbitrary code in the user's regex.