Created
October 6, 2012 09:16
-
-
Save robertklep/3844457 to your computer and use it in GitHub Desktop.
Allow a browser to soft break a string by inserting soft hyphens
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
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