Skip to content

RegExp separator #13

Description

@silverwind

I think it would be useful if split-string would, like String.prototype.split, support splitting using a RegExp as the separator. One example where this is useful is with multiple separators in series which yield empty strings:

require('split-string')('foo  bar', {separator: ' '})
// => [ 'foo', '', 'bar' ]

'foo  bar'.split(' ')
// => [ 'foo', '', 'bar' ]

But with String.prototype.split's RegExp separator, one can split on one or more separator:

> 'foo  bar'.split(/ +/)
// => [ 'foo', 'bar' ]

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions