Skip to content

Instantly share code, notes, and snippets.

@audionerd
Created May 27, 2016 18:29
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save audionerd/ceaf691e729fdfb42394703ccbb66538 to your computer and use it in GitHub Desktop.
Save audionerd/ceaf691e729fdfb42394703ccbb66538 to your computer and use it in GitHub Desktop.
Widon’t for React Native
//
//
// Widon’t for React Native
// Simply uses Unicode \u00a0 instead of  
//
// via http://webservices.blog.gustavus.edu/2007/03/20/shaun-inmans-widont-ported-to-javascript/
export const widont = (text) => text.replace(/([^\s])\s+([^\s]+)\s*$/, '$1\u00a0$2')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment