Intl.Segments

Baseline 2024
Newly available

Since April 2024, this feature works across the latest devices and browser versions. This feature might not work in older devices or browsers.

Intl.Segments のインスタンスは、テキスト文字列のセグメントを反復可能なコレクションとして保持します。Intl.Segmenter オブジェクトの segment() メソッドをコールすると、このインスタンスが返されます。

試してみましょう

const segmenterFr = new Intl.Segmenter("fr", { granularity: "word" });
const string1 = "Que ma joie demeure";

const segments = segmenterFr.segment(string1);

console.log(segments.containing(5));
// Expected output:
// Object {segment: 'ma', index: 4, input: 'Que ma joie demeure', isWordLike: true}

インスタンスメソッド

Segments.prototype.containing()

指定されたインデックスのコードユニットを含む元の文字列のセグメントを記述したオブジェクトを返します。

Segments.prototype[@@iterator]()

セグメントを反復処理するためのイテレーターを返します。

仕様書

Specification
ECMAScript® 2025 Internationalization API Specification
# sec-segments-objects

ブラウザーの互換性

Report problems with this compatibility data on GitHub
desktopmobileserver
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
Deno
Node.js
Segments
[Symbol.iterator]
containing

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support