Return the user-perceived character segments of the given string, e.g.:
const test = '๏ฌt๐๐ซ๐จโ๐ฉโ๐งโ๐ฆ';console.log([...test]); // '["๏ฌ","t","๐","๐ซ","๐จ","โ","๐ฉ","โ","๐ง","โ","๐ฆ"]'console.log(segment(test)); // '["๏ฌ","t","๐","๐ซ","๐จโ๐ฉโ๐งโ๐ฆ"]' Copy
const test = '๏ฌt๐๐ซ๐จโ๐ฉโ๐งโ๐ฆ';console.log([...test]); // '["๏ฌ","t","๐","๐ซ","๐จ","โ","๐ฉ","โ","๐ง","โ","๐ฆ"]'console.log(segment(test)); // '["๏ฌ","t","๐","๐ซ","๐จโ๐ฉโ๐งโ๐ฆ"]'
Note, this utility segments the string into grapheme clusters using Intl.Segmenter, a TC39 proposal which reached stage 4 in 2022, and may not be supported in older environments.
Intl.Segmenter
the string for which to segment characters.
Generated using TypeDoc
Return the user-perceived character segments of the given string, e.g.:
Note, this utility segments the string into grapheme clusters using
Intl.Segmenter
, a TC39 proposal which reached stage 4 in 2022, and may not be supported in older environments.