Skip to content

Instantly share code, notes, and snippets.

@neopunisher
Created September 12, 2011 20:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save neopunisher/1212288 to your computer and use it in GitHub Desktop.
Save neopunisher/1212288 to your computer and use it in GitHub Desktop.
Word break inserter w/ javascript
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