stringactionscript-3apache-flexflex4.6

Searching only for white spaces in a String in Flex


  var sample:String = filterBox.text; 

Based on the String I get from TextInput, a Button has to be disabled if the String has only white spaces and enabled only otherwise.

I want to check if the String has only white spaces.

Is/Are there any inbuilt methods in flex for this? I saw some answers for Java to use trim method. But its not available in Flex. Please help me out.


Solution

  • You can do the following

    StringUtil.trim(string);

    http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/mx/utils/StringUtil.html

    String has a lot of methods which match for patterns you can find it here. http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/String.html