Skip to content

Tiny module for splitting string by its hyphen (and hyphen like chars).

Notifications You must be signed in to change notification settings

qaraluch/qm-txt-splitByHyphen

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

logo-qm

qm-txt-splitByHyphen npm version Build Status code style: prettier

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

About

Tiny module for splitting string by its hyphen (and hyphen like chars).

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published