N ++正则表达式 - 交换订单

时间:2013-04-23 15:36:33

标签: regex notepad++

我有交换顺序块订单的任务,我需要交换订单:

    <!--Validate first group-->
     <lookupGroup name='Get 1st  value '>
        <Properties>
            <select property='A' field='B[0]'/>
        </Properties>
    </lookupGroup>
    <Include>..\Value\Test1.xml</Include>
    <Include>..\Value\Test2.xml</Include>
    <Include>..\Value\Test3.xml</Include>
    <Include>..\Value\Test4.xml</Include>

所以上面写的需要按相反的顺序排列:

    <Include>..\Value\Test2.xml</Include>
    <Include>..\Value\Test3.xml</Include>
    <Include>..\Value\Test4.xml</Include>

    <!--Validate first group-->
     <lookupGroup name='Get 1st  value '>
        <Properties>
            <select property='A' field='B[0]'/>
        </Properties>
    </lookupGroup>
    <Include>..\Value\Test1.xml</Include>

它的正确语法是什么?任何帮助,将不胜感激。先感谢您。

1 个答案:

答案 0 :(得分:0)

此正则表达式适用于您的示例数据,并且每次单击“替换”时,都会一次将“包含”元素移动到lookupGroup上方。希望这会有所帮助。

找到:( *<lookupGroup.*lookupGroup>.*\n)([^\n]*<Include>.*<.Include>)\n?

替换为:\2\n\1

要使这个工作,你必须有“。”设置为匹配换行符。