正規表現と、XMLの利用法とか
/**
* 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")
);
}
}
}
}