In case Flash no longer exists; a copy of this site is included in the Flashpoint archive's "ultimate" collection.

Dead Code Preservation :: Archived AS3 works from wonderfl.net

正規表現と、XMLの利用法とか

Get Adobe Flash player
by 9re 19 Nov 2009
/**
 * Copyright 9re ( http://wonderfl.net/user/9re )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/bKBp
 */

package {
import flash.display.Sprite;
import flash.text.TextField;
public class FlashTest extends Sprite {
    public function FlashTest() {
            
    
    
var str:String = "おちんこもんだりもしたけれど、私は元気です";
        
        
        
        
            
        var regExpReplacement:Object = {
            "(?=ん)(.(.).)" : "$2",
            "ん(?!だ)((.).(.))" : "$2$3"
        };
        
        var tf:TextField = new TextField;
        addChild(tf);
        tf.width = tf.height = 465;
        for (var reg:String in regExpReplacement) {
            var regExp:RegExp = new RegExp(reg);
            var match:Array = str.match(regExp);
            var replacement:String = regExpReplacement[reg];
            var replaced:String = str.replace(regExp, regExpReplacement[reg]);
            var tab:String = "_TAB_";
            tf.appendText((
                <data>
regExp{tab}{tab}{tab}:={tab} {regExp}
match{tab}{tab}{tab}:={tab} {match}
replacement{tab}:={tab} str.replace({regExp}, "{replacement}");

replaced{tab}{tab}={tab} {replaced}
                </data> + "\n\n\n").replace(new RegExp(tab, "g"), "\t")
            );
        }
    }
}
}