qm-txt-splitbyhyphen
v0.2.0
Published
tiny module for splitting string by its hyphen (and hyphen like chars)
Downloads
3
Readme
qm-txt-splitByHyphen
Tiny module for splitting string by its hyphen (and hyphen-like chars). It is recognizing following characters:
\u002D
- HYPHEN-MINUS (-)\u2010
- HYPHEN (‐)\u2011
- NON-BREAKING HYPHEN (‑)\u2012
- FIGURE DASH (‒)\u2013
- EN DASH (–)\u2014
- EM DASH (—)\u2015
- HORIZONTAL BAR (―)\u2E3A
- TWO-EM DASH (⸺)\u2E3B
- THREE-EM DASH (⸻)\uFE58
- SMALL EM DASH (﹘)\uFE63
- SMALL HYPHEN-MINUS (﹣)\uFF0D
- FULLWIDTH HYPHEN-MINUS (-)
Installation
$ npm i -S qm-txt-splitbyhyphen
Usage
const splitByHyphen = require("qm-txt-splitbyhyphen");
splitByHyphen("tere|fere"); //-> undefined
splitByHyphen("tere - fere"); //-> ["tere", "fere"]
splitByHyphen("a-b‐c‑d‒e–f⸺g"); //-> ["a", "b", "c", "d", "e", "f", "g"]
TitleSplit mode in witch splits string by only one hyphen e.g:
splitByHyphen("a-b-c-d-e-f-g", 1); // -> ["a", "b-c-d-e-f-g"]
splitByHyphen("a-b-c-d-e-f-g", 2); // -> ["a-b", "c-d-e-f-g"]
splitByHyphen("a-b-c-d-e-f-g", 3); // -> ["a-b-c", "d-e-f-g"]
splitByHyphen("a-b-c-d-e-f-g", 0); // default it is off -> ["a", "b", "c", "d", "e", "f", "g"]
splitByHyphen("a-b-c-d-e-f-g", 99); // -> ["a", "b", "c", "d", "e", "f", "g"]
API
splitByHyphen(string, titleSplitAt = 0)
License
MIT © qaraluch