AS3 Strip Spaces from a String


/ Published in: ActionScript 3
Save to your folder(s)



Copy this code and paste it in your HTML
  1. function stripSpaces($myString:String):String
  2. {
  3. return $myString.split(" ").join("");
  4. }
  5.  
  6.  
  7. var originalStr:String = " A B C D E F G ";
  8. trace("originalStr: "+originalStr);
  9. var withNoSpacesStr:String = stripSpaces(originalStr);
  10. trace("withNoSpacesStr: "+withNoSpacesStr);
  11.  
  12. // OUTPUT
  13. // originalStr: A B C D E F G
  14. // withNoSpacesStr: ABCDEFG

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.