Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/f1lt3r/super-split
🔪 split string by delimiter array - delimiters retained
https://github.com/f1lt3r/super-split
Last synced: 9 days ago
JSON representation
🔪 split string by delimiter array - delimiters retained
- Host: GitHub
- URL: https://github.com/f1lt3r/super-split
- Owner: F1LT3R
- License: mit
- Created: 2018-03-23T04:33:04.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2023-11-14T18:19:02.000Z (12 months ago)
- Last Synced: 2024-10-11T20:23:07.950Z (25 days ago)
- Language: JavaScript
- Homepage: https://f1lt3r.io
- Size: 4.88 KB
- Stars: 2
- Watchers: 3
- Forks: 2
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Super-Split
> 🔪 split string by delimiter array - delimiters retained
[![Build Status](https://travis-ci.org/F1LT3R/super-split.svg?branch=master)](https://travis-ci.org/F1LT3R/super-split)
[![Coverage Status](https://coveralls.io/repos/github/F1LT3R/super-split/badge.svg?branch=master)](https://coveralls.io/github/F1LT3R/super-split?branch=master)
[![NPM Version](https://img.shields.io/npm/v/super-split.svg)](https://www.npmjs.com/package/super-split)
[![XO code style](https://img.shields.io/badge/code_style-XO-5ed9c7.svg)](https://github.com/sindresorhus/xo)## Install
```
$ yarn add super-split
```## Usage
### Split a string
```js
const superSplit = require('super-split')const str = 'A+B-C'
const delimiters = ['+', '-']
const result = superSplit(str, delimiters)
```Result:
```js
['A', '+', 'B', '-', 'C']
```### Split with ANSI
```js
const str = 'I like to \u001b[34mmove it\u001b[39m, move it.'const delimiters = ['\u001b[34m', '\u001b[39m']
const result = superSplit(str, delimiters)
```Result:
```js
['I like to ', '\u001b[34m', 'move it', '\u001b[39m', ', move it.']
```### Split Array
```js
const ary = [':-)', 'o_O']const delimiters = ['-', '_']
const result = superSplit(ary, delimiters)
```Result:
```js
[':', '-', ')', 'o', '_', 'O']
```