spaces

Here’s a simple, two line function for removing spaces (can be adapted for any other character) from a string in AS3. I used it for removing any spaces typed into a Post Code.

public function stripspaces(originalstring:String):String
{
var original:Array=originalstring.split(” “);
return(original.join(“”));
}

All we’re doing is splitting the array using the space character and then joining that array back together into a string with no delimiter, thus eliminating the space.

Use Facebook to Comment on this Post