Counting Words with Intl.Segmenter

Yesterday, I gave my presentation on Intl, the browser’s built-in support for internationalization. I’ve been using this for a while now, but while researching the spec for my presentation, I ran into multiple cool aspects of it I wasn’t aware of. One feature I thought was particularly interesting was the Segementer object. MDN’s description is nice and succinct: The Intl.Segmenter object enables locale-sensitive text segmentation, enabling you to get meaningful items (graphemes, words or sentences) from a string. In particular, I thought the ability to get words would be an interesting use case. In the past, I’ve either done a lame split on " ", or used... more →
Posted in: JavaScript