Skip to content

Commit

Permalink
adds support for split character prefixes (negative numbers)
Browse files Browse the repository at this point in the history
  • Loading branch information
davelandry committed Oct 4, 2016
1 parent 591d810 commit 334ed4c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/textSplit.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const laoRange = "\u0E81-\u0EAE\u0EB0-\u0EC4\u0EC8-\u0ECB\u0ECD-\u0EDD";

const noSpaceRange = burmeseRange + chineseRange + laoRange;

const splitWords = new RegExp(`[^\\s|\\${splitChars.join("|\\")}]+(\\${splitChars.join("|\\")})*`, "g");
const splitWords = new RegExp(`(\\${splitChars.join("|\\")})*[^\\s|\\${splitChars.join("|\\")}]+(\\${splitChars.join("|\\")})*`, "g");
const japaneseChars = new RegExp(`[${japaneseRange}]`);
const noSpaceLanguage = new RegExp(`[${noSpaceRange}]`);
const splitAllChars = new RegExp(`(\\${prefixChars.join("|\\")})*[${noSpaceRange}](\\${suffixChars.join("|\\")}|\\${combiningMarks.join("|\\")})*|[a-z0-9]+`, "gi");
Expand Down
2 changes: 2 additions & 0 deletions test/textSplit.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ test("textSplit", assert => {
assert.true(arr[0] === first && arr[1] === "test", `using "${char}"`);
}

assert.equal(textSplit("-4")[0], "-4", "string starting with split character");

const chinese = textSplit("里句。");
assert.true(chinese[0] === "里" && chinese[1] === "句。", "simplified chinese");

Expand Down

0 comments on commit 334ed4c

Please sign in to comment.