esamattis / esamattis/underscore.string
words' regex argument crashes with quantifiers
- Dominant language
- JavaScript
- Stars
- 3.4k
- Forks
- 367
- PR merge metrics
- No merged PRs in 30d
Description
As soon as I add a quantifier in `words`' pattern argument, I get an error I wouldn't with the original JS method split:
``` javascript
var a = _('1 2, 3').words(/, +/);
// => SyntaxError: Invalid regular expression: /^, ++|, ++$/: Nothing to repeat
var b = _('1 2, 3').words(/, */);
// => SyntaxError: Invalid regular expression: /^, *+|, *+$/: Nothing to repeat
var c = _.words('1 2, 3', /, */)
// => SyntaxError: Invalid regular expression: /^, *+|, *+$/: Nothing to repeat
```
See this jsfiddle: http://jsfiddle.net/ejoubaud/J9gn9/
Unrelated: Why use the obscure name `words` instead of the basic JS/Ruby well-known `split` ? I'd strongly +1 an alias.
Apart from that awesome job with this lib guys, thank you very much.
Contributor guide
Assessment
This issue has not been assessed yet.