Created
March 4, 2013 19:40
-
-
Save quickredfox/5084870 to your computer and use it in GitHub Desktop.
Split a javascript utf-16 string into an array of graphemes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var splitGraphemes = function( string ) { | |
var matches = string.match( /([A-Z]{1})|([^A-Z]{2})|([^A-Z]{1})/gi ); | |
if( !matches) return []; | |
return Array.prototype.slice.call( matches ); | |
} |
Actually, no. It's crap. Dont use this.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Note: This is context specific, YMMV.