0
votes

I got a text that ends on every single line with .|

And I need to replace the .| on every 5th line with .}

I did it with this code in search (((.|)*\s*\s*){5}) and replace $1.}

But that adds every 5th line a new line with .} on the beginning, but doesn't replace the .| on the end of the 5th.

And I can't figure out how to modify the code for my need!

Maybe some modification ideas for this code?

3

3 Answers

1
votes

1.Put the cursor in front of the first letter of the whole text

2.Click "Start Recording"

3.Press Down Arrow 4 times

4.Press End once

5.Press Backspace once

6.Press } once

7.Press Right Arrow once

8.Click "Stop Recording"

10.Click "Run a Macro Multiple Times..."

11.Select "Run until the end of file"

12.Click "Run"

0
votes

How about:

Fin what: ((?:.+\R){4}.+)\|(\R)
Replace with: $1}$2

Then clic on Replace All

Make sure that Dot matches newline is NOT checked.

0
votes

You can do it but looking for for matching lines and then a nother line that matches up to the point you want to replace.

With regex and wraparound checked and ". matches newline" not checked, searchign forward form start of file.

search:

((^.*\.\|\r\n){4}(^.*))\.\|\r\n

That 4 times form the start of a line match all characters including the .| at the EoL and alos match all the characters on the next line up to the .| at the EoL.

replace:

\1.}\r\n

Replace everything in the 1st capture group with itself followed by you new end of line sequence.