forked from: 正規表現エディタ

by uwi forked from 正規表現エディタ (diff: 108)
♥5 | Line 50 | Modified 2009-06-28 12:24:17 | MIT License
play

ActionScript3 source code

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

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
 paddingBottom="5"
 paddingTop="5"
 paddingLeft="5"
 paddingRight="5"
 applicationComplete="onApplicationComplete()"
>
    <!-- 何という別物 -->
    <mx:Script>
    <![CDATA[
        import flash.desktop.*;
        import flash.events.*;
        
        private function onApplicationComplete() : void
        {
            _tasrc.text = "Hello, there!";
            _tiexp.text = "l+";
            _tiafter.text = "rr";
            onChange();
        }
        
        private function onChange() : void
        {
            if(_tiexp.text == "")return;
            
            var opt : String = "gx";
            if(_cbdotall.selected)opt += "s";
            if(_cbignoreCase.selected)opt += "i";
            if(_cbmultiline.selected)opt += "m";
            var reg : RegExp = new RegExp(_tiexp.text, opt);
            
            _tadst.text = _tasrc.text.replace(reg, _tiafter.text);
            _tasrc.htmlText = _tasrc.text.replace(reg, "<font color='#ff0000'><u>$&</u></font>");
            _tadst.enabled = true;
        }
    ]]>
    </mx:Script>

    <mx:HBox width="100%">
        <mx:Label text="正規表現" />
        <mx:TextInput id="_tiexp" width="100%" change="onChange()" restrict=" -&#xffee;"/>
    </mx:HBox>
    <mx:HBox width="100%">
        <mx:Label text="変換後" />
        <mx:TextInput id="_tiafter" width="100%" change="onChange()" restrict=" -&#xffee;"/>
    </mx:HBox>
    <mx:HBox width="100%">
        <mx:CheckBox id="_cbdotall" label="dotall" selected="false" change="onChange()" />
        <mx:CheckBox id="_cbignoreCase" label="ignoreCase" selected="true" change="onChange()" />
        <mx:CheckBox id="_cbmultiline" label="multiline" selected="false" change="onChange()" />
    </mx:HBox>
    <mx:TextArea id="_tasrc" width="100%" height="100%" change="onChange()" restrict=" -&#xffee;"/>
    <mx:TextArea id="_tadst" width="100%" height="100%" editable="false"/>
</mx:Application>