Created
June 14, 2011 02:30
-
-
Save zeuxisoo/1024198 to your computer and use it in GitHub Desktop.
Add space between words
This file contains hidden or 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 space_text(my_text){ | |
| var len = my_text.length; | |
| var text = my_text; | |
| var text2 = text.charAt(0); | |
| for(var i = 1; i < len-1; i++) { | |
| text2 += text.charAt(i); | |
| if(text.charCodeAt(i) > 128 && text.charAt(i+1) != " " && text.charAt(i+1) != "\n") | |
| text2 += " "; | |
| } | |
| text2 += text.charAt(len-1); | |
| len = text2.length; | |
| var text3 = text2.charAt(0); | |
| for(var i = 1; i < len-1; i++) { | |
| if(text2.charCodeAt(i) > 128 && text2.charAt(i-1) != " " && text2.charAt(i-1) != "\n") { | |
| text3 += " "; | |
| } | |
| text3 += text2.charAt(i); | |
| } | |
| text3 += text2.charAt(len-1); | |
| return text3; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment