Moving regular lines down by a specific amount of lines

Viewed 53

I am looking to move a specific line, in this Case "MATCHCODE>(.*?)</MATCHCODE" below the line Radius2>0</Radius2.

        <LProfil>
            <ID>2</ID>
            <MATCHCODE>L 10x10x2,0</MATCHCODE>
            <Schenkela>10</Schenkela>
            <Schenkelb>10</Schenkelb>
            <Schenkelstaerke_S>2,0</Schenkelstaerke_S>
            <Radius1>0</Radius1>
            <Radius2>0</Radius2>
        </LProfil>
        <LProfil>
            <ID>3</ID>
            <MATCHCODE>L 12x12x2,0</MATCHCODE>
            <Schenkela>12</Schenkela>
            <Schenkelb>12</Schenkelb>
            <Schenkelstaerke_S>2,0</Schenkelstaerke_S>
            <Radius1>0</Radius1>
            <Radius2>0</Radius2>
        </LProfil>

so the target outcome would be like this

        <LProfil>
            <ID>2</ID>
            <Schenkela>10</Schenkela>
            <Schenkelb>10</Schenkelb>
            <Schenkelstaerke_S>2,0</Schenkelstaerke_S>
            <Radius1>0</Radius1>
            <Radius2>0</Radius2>
            <MATCHCODE>L 10x10x2,0</MATCHCODE>
        </LProfil>
        <LProfil>
            <ID>3</ID>
            <Schenkela>12</Schenkela>
            <Schenkelb>12</Schenkelb>
            <Schenkelstaerke_S>2,0</Schenkelstaerke_S>
            <Radius1>0</Radius1>
            <Radius2>0</Radius2>
            <MATCHCODE>L 12x12x2,0</MATCHCODE>
        </LProfil>

I have already used the regex command to alter the database in multiple ways but could not find a way to move the lines down. I have tried the following:

  • making a macro, while moving down the target line manually using the keyboard. I could not manage to create a consistent makro that would do the job.

  • using the \v special character to move the line MATCHCODE>(.*?)</MATCHCODE down. I could not get the \v vertical tab to work at all

  • I also tried to copy the whole starting block in the find what window like so:

Find what:
<MATCHCODE>(.*?)</MATCHCODE>\n<Schenkela>(.*?)</Schenkela>\n<Schenkelb>(.*?)</Schenkelb>\n<Schenkelstaerke_S>1,0</Schenkelstaerke_S>\n<Radius1>0</Radius1>\n<Radius2>0</Radius2>
Replace with:
<Schenkela>\2</Schenkela>\n<Schenkelb>\3</Schenkelb>\n<Schenkelstaerke_S>10</Schenkelstaerke_S>\n<Radius1>0</Radius1>\n<Radius2>0</Radius2>\n<MATCHCODE>\1</MATCHCODE>

I am aware that the last try was pretty stupid but that's when I knew that I needed help with my problem, and since no-one here at work knows how to cod, I am looking for help here.

I don't have a programming background abut got into Notepad++ to hack the profile databases of a CAD software we are using at work. This site helped me a lot to solve any previous problems but I can't seem to find the right approach to the current problem I am facing.

TLDR: I am looking for a way to move a line with recuring words and random numbers to a now location down a set amount of lines or down after a recuring line.

1 Answers

If you are familiar with notepad++ find&replace function,
Then try this regex,
Find what: (\s+<MATCHCODE.*)((\n.*){5})
Replace all with: $2$1

this what I have captured with my regex in two groups

enter image description here

After Replace All

enter image description here

Related