Space Removal

Submitted by:Jhon Brain

Date added:11 October, 2011

Category:ActionScript

In the same way you often need to format data being sent from Flash, you sometimes need to 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.

Tags: remove space

Code Snippet:

    function stripSpaces(string:String):String
{
var s:String = string;
return s.split(" ").join("");
}
 
 

Comments