While you can make dynamically-created RegExp's (as per the other responses to this question), I'll echo my comment from a similar postsimilar post: The functional form of String.replace() is extremely useful and in many cases reduces the need for dynamically-created RegExp objects. (which are kind of a pain 'cause you have to express the input to the RegExp constructor as a string rather than use the slashes /[A-Z]+/ regexp literal format)