Skip to content

Instantly share code, notes, and snippets.

@quickredfox
Created March 4, 2013 19:40
Show Gist options
  • Select an option

  • Save quickredfox/5084870 to your computer and use it in GitHub Desktop.

Select an option

Save quickredfox/5084870 to your computer and use it in GitHub Desktop.
Split a javascript utf-16 string into an array of graphemes.
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 );
}
@quickredfox
Copy link
Copy Markdown
Author

Note: This is context specific, YMMV.

@quickredfox
Copy link
Copy Markdown
Author

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