I'm not sure why you're creating a new RegExp each time.  You can just have the initialization code below set `_invalidChars` directly to a regexp instance (e.g. `_invalidChars = /\/?:|*/;` for the Mac case) and then reuse it every time.