Stefan Judis stefanjudis.com

Split JS strings into sentences, words or graphemes with `Intl.Segmenter`  ↦

If you’ve ever had to split a string into sentences, you may have reached for a naive regular expression:

'Hello! How are you?'.split(/[.!?]/);

Instead of giving yourself two problems, Stefan Judis says maybe reach for Intl.Segmenter, which he shows is quite sophisticated and supported everywhere but Firefox.


Discussion

Sign in or Join to comment or subscribe

Player art
  0:00 / 0:00