instead of iterating over chars, what do you think of a join here?
```javascript
return new RegExp("(" + chars.join('|') + ")", "g");
```