greedy-split
v1.0.555
Published
splits string with limit the right way.
Downloads
121
Maintainers
Keywords
Readme
greedy-split
splits string with limit the right way.
install:
$ npm install --save greedy-split
use:
const greedySplit = require('greedy-split');
console.log('1|2|3|4'.split('|', 3)); //logs ['1', '2', '3']
console.log(greedySplit('1|2|3|4', '|', 3)); //logs ['1', '2', '3|4']
console.log('1|2|3|4'.split(/\|+/, 3)); //logs ['1', '2', '3']
console.log(greedySplit('1|2||3|4', /\|+/, 3)); //logs ['1', '2', '3|4']
that is all.