Open this example in the interactive library
Source code
const words = new Intl.Segmenter("en", { granularity: "word" });
console.log(
[...words.segment("Hello, world!")]
.filter((part) => part.isWordLike)
.map((part) => part.segment),
);
Sample output
[ 'Hello', 'world' ]
