added support for regular expressions in stringReplace method