left-split

1.0.0 • Public • Published

left-split

Split string capture group is captured to the left hand array item.

Capturing parenthesis return the separator as a distinct array element. left-split puts it at the end of the left hand array item.

Install

npm install left-split

Usage

 
leftsplit = require('left-split')
 
'foo bar'.split(/(\s)/)
// => ['foo', ' ', 'bar']
 
leftsplit('foo bar', /(\s)/)
// => ['foo ', 'bar']
 
'foo\nbar\n'.split(/(\r?\n)/)
// => ['foo', '\n', 'bar', '\n', '']
 
leftsplit('foo\nbar\n', /(\r?\n)/)
// => ['foo\n', 'bar\n', '']
 

Package Sidebar

Install

npm i left-split

Weekly Downloads

2,441

Version

1.0.0

License

MIT

Last publish

Collaborators

  • jramsay