peach a19a732be8 commit message | 2 anni fa | |
---|---|---|
.. | ||
index.d.ts | 2 anni fa | |
index.js | 2 anni fa | |
license | 2 anni fa | |
package.json | 2 anni fa | |
readme.md | 2 anni fa |
Split a string on the first occurrence of a given separator
This is similar to String#split()
, but that one splits on all the occurrences, not just the first one.
$ npm install split-on-first
const splitOnFirst = require('split-on-first');
splitOnFirst('a-b-c', '-');
//=> ['a', 'b-c']
splitOnFirst('key:value:value2', ':');
//=> ['key', 'value:value2']
splitOnFirst('a---b---c', '---');
//=> ['a', 'b---c']
splitOnFirst('a-b-c', '+');
//=> ['a-b-c']
Type: string
The string to split.
Type: string
The separator to split on.
MIT © Sindre Sorhus