I want to make my alphanumeric regex dynamic in a way that it takes the allowed special characters with it as an argument by the user. Following is my code ... I am getting quot
You've actually escaped the quote, so you have to escape the escape
var regex = new RegExp("^[a-z0-9_\\" + allowed + "]+$", "i");