split-retain

2019-11-22 admin

split-retain是什么

什么是split-retain,Split a string and preserve the delimiters.

split-retain使用教程帮助文档

split-retain

Split a string and preserve the delimiters.

  • Install
  • Examples
  • Documentation
    • Arguments
    • Results
  • Tests
  • Coverage
  • TODO
  • License

Install

Node.js npm install split-retain --save

var splitRetain = require('split-retain');

Browser Include the full or minified version on your webpage from browser/, then use splitRetain(...).

<script src="path/to/split-retain.min.js">

Examples

splitRetain('home/jack/images/photo12.jpeg', '/')
// ['home/', 'jack/', 'images/', 'photo12.jpeg']

splitRetain('home/jack/images/photo12.jpeg', '/', { leadingSeparator: true })
// ['home', '/jack', '/images', '/photo12.jpeg']

...

Documentation

splitRetain(string, separator[, options])

Arguments

argument type desription
string String string to split
separator String

——— RegExp | single character ——— must have grouping parentheses and global flag, e.g. /(\d+)/g | | [options = {}] | Object | — | | [options.leadingSeparator = false] | Boolean | if true, the separator will be placed at the beginning of the split tokens |

Results

property type description
@return String[] array of split tokens
@throws Error on incorrect argument types

Tests

npm test

Coverage

npm run cover

TODO

  • create ‘publish steps’
  • replace browserify with UMD?
  • more examples in Examples
  • changelog
  • lint

License

MIT

本站文章除注明转载外,均为本站原创或编译。欢迎任何形式的转载,但请务必注明出处。

转载请注明:文章转载自 JavaScript中文网 [https://www.javascriptcn.com]

本文地址:https://www.javascriptcn.com/read-79682.html

文章标题:split-retain

回到顶部