Split string by any separator excluding brackets, quotes and escaped characters
npm install string-split-byjs
var split = require('string-split-by')
split('a."b.c".d.{.e.f.g.}.h', '.')
// ['a', '"b.c"', 'd', '{.e.f.g.}', 'h']
split('a."b.c".d.{.e.f.g.}.h', '.', {ignore: '""'})
// ['a', '"b.c"', 'd', '{', 'e', 'f', 'g', '}', 'h']
`
API
$3
Return array with parts split from string by a separator, which can be whether _String_ or _RegExp_. Options can define:
Option | Default | Meaning
---|---|---
ignore | ['"', "'", '', '“”', '«»', '[]', '()', '{}']` | Avoid splitting content enclosed in the character pairs. Can be a string or a list of strings.
escape | true | Avoid splitting at the escaped separator, eg. \. won't be separated by '.'` separator.