Standard built-ins
Intl.Segmenter.prototype.segment()
Return an iterable Segments object for a string, using configured granularity. Records include UTF-16 index and segment, with word-likeness for word granularity.
Formal Syntax & Structure
javascript syntaxjavascript
formatter.segment(string)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| string | String | Text to segment. |
Return Value
Segments
Iterable segmentation result.
Working Example
Example Snippetjavascript
const s=new Intl.Segmenter("en",{granularity:"grapheme"});console.log([...s.segment("é")].length);