lj_zhgd-app/zhgd-app/node_modules/string-split-by
zzyuan 2a6b2173f7 前端app提交 2024-08-29 15:23:50 +08:00
..
.eslintrc.json first commit 2024-08-06 16:27:09 +08:00
.travis.yml first commit 2024-08-06 16:27:09 +08:00
index.js first commit 2024-08-06 16:27:09 +08:00
package.json 前端app提交 2024-08-29 15:23:50 +08:00
readme.md first commit 2024-08-06 16:27:09 +08:00
test.js first commit 2024-08-06 16:27:09 +08:00

readme.md

string-split-by unstable Build Status

Split string by a separator with respect to brackets, quotes and escape markers. Optimized version of string-split.

Usage

npm install string-split-by

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

parts = splitBy(string, separator, options?)

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.

License

© 2018 Dmitry Yv. MIT License