Skip to content

Instantly share code, notes, and snippets.

@seanghay
Created September 13, 2021 17:39
Show Gist options
  • Select an option

  • Save seanghay/722427c618d2f35da76f6d5dc33a7ec2 to your computer and use it in GitHub Desktop.

Select an option

Save seanghay/722427c618d2f35da76f6d5dc33a7ec2 to your computer and use it in GitHub Desktop.
const segmenter = new Intl.Segmenter("km", {granularity: "word"});
const input = "នឹកបងឬនឹកគេ?";
const segments = segmenter.segment(input);
for (const {segment} of segments) {
console.log(segment)
}
// OUTPUT:
// នឹក
// បង
// ឬ
// នឹក
// គេ
// ?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment