简体   繁体   English

Notepad ++将。|每5行替换为。}

[英]Notepad++ replace .|every 5th line with .}

I got a text that ends on every single line with .| 我得到的文本以.|结尾.|

And I need to replace the .| 而且我需要替换.| on every 5th line with .} 在每5行加上.}

I did it with this code in search (((.|)*\\s*\\s*){5}) and replace $1.} 我在搜索(((.|)*\\s*\\s*){5})使用此代码完成了此操作,并替换了$1.}

But that adds every 5th line a new line with .} on the beginning, but doesn't replace the .| 但这会在第5行的开头添加一个新行,并带有.} ,但不会替换.| on the end of the 5th. 在5月底。

And I can't figure out how to modify the code for my need! 而且我不知道如何根据需要修改代码!

Maybe some modification ideas for this code? 也许对此代码有一些修改想法?

1.Put the cursor in front of the first letter of the whole text 1.将光标放在整个文本的第一个字母前面

2.Click "Start Recording" 2.点击“开始录制”

3.Press Down Arrow 4 times 3.按下向下箭头四次

4.Press End once 4.按一次结束

5.Press Backspace once 5.按退格键一次

6.Press } once 6.按一次}

7.Press Right Arrow once 7.按一次向右箭头

8.Click "Stop Recording" 8.单击“停止录制”

10.Click "Run a Macro Multiple Times..." 10.单击“多次运行宏...”

11.Select "Run until the end of file" 11.选择“运行到文件末尾”

12.Click "Run" 12.单击“运行”

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. 选中正则表达式和自动换行,并且未选中“。match newline”,则搜索格式为文件开头。

search: 搜索:

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

That 4 times form the start of a line match all characters including the .| 行首的那4次匹配所有字符,包括。|。 at the EoL and alos match all the characters on the next line up to the .| 在EoL和alos处匹配下一行中的所有字符,直到。|。 at the EoL. 在EoL。

replace: 更换:

\\1.}\\r\\n \\ 1。} \\ r \\ n

Replace everything in the 1st capture group with itself followed by you new end of line sequence. 替换第一捕获组中的所有内容,然后替换为新的行尾。

How about: 怎么样:

Fin what: ((?:.+\\R){4}.+)\\|(\\R) 查找什么: ((?:.+\\R){4}.+)\\|(\\R)
Replace with: $1}$2 替换为: $1}$2

Then clic on Replace All 然后选择全部替换

Make sure that Dot matches newline is NOT checked. 确保未选中Dot matches newline

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM