正規表現エディタ
♥2 |
Line 70 |
Modified 2009-06-22 15:23:29 |
MIT License
archived:2017-03-10 09:25:33
ActionScript3 source code
/**
* Copyright famibee2 ( http://wonderfl.net/user/famibee2 )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/i6uF
*/
package {
import flash.display.Sprite;
import flash.text.TextField;
import flash.text.TextFieldType;
import flash.text.TextFormat;
import flash.events.Event;
public class Main extends Sprite {
private const tfExp:TextField = new TextField();
private const tfrepl:TextField = new TextField();
private const tfInp:TextField = new TextField();
private const tfOut:TextField = new TextField();
public function Main() {
tfExp.x = 20;
tfExp.y = 0;
tfExp.width = stage.stageWidth - tfExp.x*2;
tfExp.height = 24;
tfExp.border = true;
tfExp.background = true;
tfExp.backgroundColor = 0xFFcccc;
tfExp.defaultTextFormat = new TextFormat(null, 24);
tfExp.type = TextFieldType.INPUT;
tfExp.text = "l+";
tfExp.addEventListener(Event.CHANGE, chg);
addChild(tfExp);
tfrepl.x = tfExp.x;
tfrepl.y = tfExp.y +tfExp.height;
tfrepl.width = tfExp.width;
tfrepl.height = tfExp.height;
tfrepl.border = true;
tfrepl.background = true;
tfrepl.backgroundColor = 0xccccFF;
tfrepl.defaultTextFormat = new TextFormat(null, 24);
tfrepl.type = TextFieldType.INPUT;
tfrepl.text = "<font color='#ff0000'><u>$&</u></font>";
tfrepl.addEventListener(Event.CHANGE, chg);
addChild(tfrepl);
tfInp.x = tfExp.x;
tfInp.y = tfrepl.y + tfrepl.height;
tfInp.width = stage.stageWidth - (tfExp.x *2);
tfInp.height = (stage.stageHeight - tfInp.y)/2;
tfInp.multiline = true;
tfInp.wordWrap = true;
tfInp.border = true;
tfInp.background = true;
tfInp.backgroundColor = 0xccFFcc;
tfInp.defaultTextFormat = new TextFormat(null, 24);
tfInp.type = TextFieldType.INPUT;
tfInp.text = "Hello 'World'!\rcall";
tfInp.addEventListener(Event.CHANGE, chg);
addChild(tfInp);
tfOut.width = tfInp.width;
tfOut.height = tfInp.height;
tfOut.x = tfExp.x;
tfOut.y = tfInp.y + tfInp.height;
tfOut.multiline = true;
tfOut.wordWrap = true;
tfOut.border = true;
tfOut.background = true;
tfInp.backgroundColor = 0xeeeeee;
tfOut.defaultTextFormat = new TextFormat(null, 24);
tfOut.text = "Hello 'World'!";
addChild(tfOut);
tfExp.dispatchEvent(new Event(Event.CHANGE));
}
private function chg(e:Event):void {
const reg:RegExp = new RegExp(tfExp.text, "gx");
tfOut.htmlText = tfInp.text.replace(reg, tfrepl.text);
}
}
}