Skip to content

Instantly share code, notes, and snippets.

@robertklep
Created October 6, 2012 09:16
Show Gist options
  • Save robertklep/3844457 to your computer and use it in GitHub Desktop.
Save robertklep/3844457 to your computer and use it in GitHub Desktop.
Allow a browser to soft break a string by inserting soft hyphens
String.prototype.softbreak = function(minimum_size) {
return this
.toString()
.replace(
new RegExp('(.{' + (minimum_size || 5) + '})', 'g'),
'$1­'
);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment