sublime text 正则替换分组

经常需要批量替换一些配置信息,使用sublime text2即可完成。

替换为分组的信息:

搜索: ([“>])5
替换值:\17

\1会自动替换为搜索正则中的匹配的第一个分组的内容,7为普通字符串

替换前:

image

 

<!– 华丽的分割线  排重作业 –>
<node id=”51″ text=”排重编辑” >
    <statuses>
        <status id=”510″ type=”in” text=”编辑中” taskType=”40″ planType=”40″/>
        <status id=”515″ type=”out” text=”编辑完成”>
            <conditions>
                <in>510</in>
            </conditions>
        </status>
    </statuses>
</node>
<node id=”53″ text=”二检”>
    <statuses>
        <status id=”530″ type=”in” text=”质检中” taskType=”42″ planType=”42″>
            <initFlow createTask=”true”>
                <assign exec=”true” taskStatus=”1″ assignType=”4″/>
            </initFlow>
            <dealServers>
                <server name=”sampling”/>
            </dealServers>
        </status>
        <status id=”535″ type=”out” text=”质检通过”>
            <conditions>
                <in>530</in>
                <flowCons>
                    <table name=”meta_param”>name=”next_section” and parameter=1</table>
                </flowCons>
            </conditions>
        </status>
        <status id=”536″ type=”out” text=”质检返修”>
            <conditions>
                <in>530</in>
                <flowCons>
                    <table name=”meta_param”>name=”next_section” and parameter=3</table>
                </flowCons>
            </conditions>
        </status>
       <status id=”537″ type=”out” text=”质检返工”>
            <conditions>
                <in>530</in>
                <flowCons>
                    <table name=”meta_param”>name=”next_section” and parameter=2</table>
                </flowCons>
            </conditions>
        </status>
    </statuses>
</node>
<node id=”54″ text=”质检返修” >
    <statuses>
        <status id=”540″ type=”in” text=”二检返修” taskType=”43″ planType=”40″>
            <initFlow createTask=”true”>
                <assign exec=”true” taskStatus=”1″ assignType=”2″/>
            </initFlow>
            <dealServers>
                <server name=”sampling”/>
            </dealServers>
        </status>
        <status id=”545″ type=”out” text=”返修完成”>
            <conditions>
                <in>540</in>
            </conditions>
        </status>
    </statuses>
</node>
<node id=”55″ text=”质检返工” >
    <statuses>
        <status id=”550″ type=”in” text=”返工编辑中” taskType=”44″ planType=”40″>
            <initFlow createTask=”true”>
                <assign exec=”true” taskStatus=”1″ assignType=”2″/>
            </initFlow>
        </status>
        <status id=”555″ type=”out” text=”返工完成”>
            <conditions>
                <in>550</in>
            </conditions>
        </status>
    </statuses>
</node>

 

替换后:

image

About 智足者富

http://chenpeng.info

发表评论

电子邮件地址不会被公开。 必填项已用*标注

您可以使用这些HTML标签和属性:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>