split-on-first-occurrence

Split a string on the first occurrence of a char

Usage no npm install needed!

<script type="module">
  import splitOnFirstOccurrence from 'https://cdn.skypack.dev/split-on-first-occurrence';
</script>

README

split-on-first-occurrence

NPM version NPM downloads Build Status

Install

$ npm install --save split-on-first-occurrence

Usage

const split = require('split-on-first-occurrence')

split('Author: EGOIST COOL', ' ')
//=> ['Author:', 'EGOIST COOL']

// split by a string
split('Hello\n\nWorld\n\n!', '\n\n')
//=> ['Hello', 'World\n\n!']

API

split(input, char)

input

Type: string

The string to split.

char

Type: string

The seperator char or chars.

Contributing

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request :D

License

MIT © EGOIST