In the same way you often need to format data being sent from Flash, you sometimes need format data being received. This function takes a string and removes all spaces from it. Here we use the split method of the String class to split the string into an Array and then call the join method of the Array class to convert it back to a string. This is useful when dealing with a string you know cannot contain spaces such as an email address, URL or phone number. This returns a new string, leaving the input string unchanged.
- function stripSpaces(string:String):String
- var s:String = string;
- return s.split(" ").join("");
You need to login to post a comment.