Chapter 12 Example 6

by actionscriptbible
♥0 | Line 14 | Modified 2009-07-23 05:58:07 | MIT License
play

ActionScript3 source code

/**
 * Copyright actionscriptbible ( http://wonderfl.net/user/actionscriptbible )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/9l2S
 */

package {
  import com.actionscriptbible.Example;
  
  public class ch12ex6 extends Example {
    public function ch12ex6() {
      //SPLITTING
      
      var haiku:String = 
      "Oh ActionScript three/ you make coding delightful / I think you are neat.";
      
      var lineDelimiter:RegExp = /\s*\/\s*/;
      var lines:Array = haiku.split(lineDelimiter);
      
      for (var i:int = 0; i < lines.length; i++) {
          trace(i, lines[i]);
      }
      //0 Oh ActionScript three
      //1 you make coding delightful
      //2 I think you are neat.
    }    
  }
}