views:

37

answers:

1

How can one remove whitespace from a string in as3?

I would like to be able to remove all carriage returns, spaces, tabs etc.

+2  A: 

You can use RegExp.

var rex:RegExp = /[\s\r\n]*/gim;
var str:String = "This is            a string.";

str = str.replace(rex,'');
// str is now "Thisisastring."
Robusto