Flash / Flex / ActionScript/String/reverse

Материал из Web эксперт
Перейти к: навигация, поиск

Reversing a String by Word or by Character

 
package{
  import flash.display.Sprite;
  
  public class Main extends Sprite{
    public function Main(){
        var example:String = "hello dear reader";
        var words:Array = example.split( " " );
        words.reverse(  );
        
        var exampleRevByWord:String = words.join( " " );
        
        trace( exampleRevByWord );
        
        var characters:Array = example.split( "" );
        
        characters.reverse(  );
        
        var exampleRevByChar:String = characters.join( "" );
        
        trace( exampleRevByChar );
        
    }
  }
}