Support passing in of RegExps for regex property

Pretty straightforward change. In the current implementation of replace, an error will be thrown error if you pass in a RegExp as the value of `regex`. This isn't a big deal if you're using replace from the command line, but it's kind of annoying if you're using it through the programmatic interface.