Regular Expression Splitter 2

by rfkrocktk forked from Simple Console (diff: 7)
♥0 | Line 23 | Modified 2010-10-13 12:36:05 | MIT License
play

ActionScript3 source code

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

// forked from rfkrocktk's Simple Console
package {
    import flash.text.TextFormat;
    import flash.text.TextField;
    import flash.display.Sprite;    
    
    public class RegExpSplitter extends Sprite {
        
        private var textfield:TextField;
        
        public function RegExpSplitter() {
            this.textfield = new TextField();
            this.textfield.x = this.textfield.y = 10;
            this.textfield.width = this.stage.stageWidth;
            this.textfield.height = this.stage.stageHeight;
            this.textfield.defaultTextFormat = new TextFormat("Courier New");
            
            this.addChild(this.textfield);
            
            output("RegExp Splitter");
            output("---------------------------");
            
            output(new String("%d [%l] %abc{def} %(%another{} pattern) %2.0logger %20.20logger \% ")
                .split(/((?<!\\)%(?:(?:\\-?[0-9]+)?\\.?(?:\\-?[0-9]+))?(?:[\w\.\-]+)?(?:\(.+?\))?(?:\{.+?\})?)/).join(""));
        }
        
        public function output(message:String):void {
            this.textfield.appendText(message + "\n");
        }
    }
}