Fix replace task

This pull request fixes 2 bugs:
* in CLI mode, RegExp objects couldn't be used : params.regex is created in the vm which has its own global RegExp object, so the `param.regex instanceof RegExp` test failed.
* empty flags were replaced by the default 'mg' value.