Created
September 12, 2011 20:21
-
-
Save neopunisher/1212288 to your computer and use it in GitHub Desktop.
Word break inserter w/ javascript
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
function wbr(str, num) { if(num == undefined) num = 3; | |
return str.replace(RegExp("(\\w{" + num + "})(\\w)", "g"), function(all,text,char){ | |
return text + "<wbr>" + char; | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment