Posted By

Meestercor on 05/27/08


Tagged

textmate text Punt spatie autoformat tekst


Versions (?)

Autoformat text


 / Published in: Other
 

  1. function autoFormat(what:String, numSpaces:Number):String {
  2. var tmp:Array = what.split(".");
  3. if (!numSpaces) {
  4. numSpaces = 1;
  5. }
  6. var tmpStr:String = "";
  7. for (var i:Number = numSpaces; i>0; i--) {
  8. tmpStr += " ";
  9. }
  10. for (var i in tmp) {
  11. while (tmp[i].charAt(0) === " ") {
  12. tmp[i] = tmp[i].slice(1, tmp[i].length);
  13. }
  14. tmp[i] = tmp[i].charAt(0).toUpperCase()+tmp[i].slice(1, tmp[i].length);
  15. }
  16.  
  17. return tmp.join("."+tmpStr).split(" i ").join(" I ").split(" i'").join(" I'");
  18. }

Report this snippet  

You need to login to post a comment.