Remove whitespace in as3

后端 未结 4 1810
清歌不尽
清歌不尽 2021-02-19 05:47

How can one remove whitespace from a string in as3?

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

4条回答
  •  攒了一身酷
    2021-02-19 06:39

    Tested and works on AnimateCC for iOS air app:

    // Regular expressions
    var spaces:RegExp = / /gi; // match "spaces" in a string
    var dashes:RegExp = /-/gi; // match "dashes" in a string
    
    // Sample string with spaces and dashes
    loginMC.userName.text = loginMC.userName.text.replace(spaces, ""); // find and replace "spaces"
    loginMC.userName.text = loginMC.userName.text.replace(dashes, ":"); // find and replace "dashes"
    
    trace(loginMC.userName.text);
    

提交回复
热议问题