super-split
v1.1.0
Published
🔪 split string by delimiter array - delimiters retained
Downloads
10,312
Maintainers
Readme
Super-Split
🔪 split string by delimiter array - delimiters retained
Install
$ yarn add super-split
Usage
Split a string
const superSplit = require('super-split')
const str = 'A+B-C'
const delimiters = ['+', '-']
const result = superSplit(str, delimiters)
Result:
['A', '+', 'B', '-', 'C']
Split with ANSI
const str = 'I like to \u001b[34mmove it\u001b[39m, move it.'
const delimiters = ['\u001b[34m', '\u001b[39m']
const result = superSplit(str, delimiters)
Result:
['I like to ', '\u001b[34m', 'move it', '\u001b[39m', ', move it.']
Split Array
const ary = [':-)', 'o_O']
const delimiters = ['-', '_']
const result = superSplit(ary, delimiters)
Result:
[':', '-', ')', 'o', '_', 'O']