splitGraphemeClusters

Split a string by its grapheme cluster breaks.

Usage

var splitGraphemeClusters = require( '@stdlib/string/split-grapheme-clusters' );

splitGraphemeClusters( str )

Splits a string by its grapheme cluster breaks.

var out = splitGraphemeClusters( 'café' );
// returns [ 'c', 'a', 'f', 'é' ]

out = splitGraphemeClusters( '🍕🍕🍕' );
// returns [ '🍕', '🍕', '🍕' ]

Examples

var splitGraphemeClusters = require( '@stdlib/string/split-grapheme-clusters' );

var out = splitGraphemeClusters( 'abc' );
// returns [ 'a', 'b', 'c' ]

out = splitGraphemeClusters( 'Iñtërnâtiônàlizætiøn' );
// returns [ 'I', 'ñ', 't', 'ë', 'r', 'n', 'â', 't', 'i', 'ô', 'n', 'à', 'l', 'i', 'z', 'æ', 't', 'i', 'ø', 'n' ]

out = splitGraphemeClusters( '\uD834\uDD1E' );
// returns [ '𝄞' ]

out = splitGraphemeClusters( '! !' );
// returns [ '!', ' ', '!' ]

out = splitGraphemeClusters( '' );
// returns []
Did you find this page helpful?