问题描述
在记事本++中有删除每隔一行或第n行的方法吗?我有一个庞大的数据列表,我需要减小的大小。
Is there a way in Notepad++ to delete every other or nth line? I have a massive list of data and I need to reduce the size.
数据本身不是那么重要,从一个列表中的10,000项我只需要一个选择of 5,000
The data itself is not that important and out of a list of 10,000 items I only need a selection of 5,000
推荐答案
我认为这是一个奇怪的想法,尝试用Notepad ++,但我喜欢一个挑战,所以我决定
I think it's a strange idea to try to do with Notepad++, but I like a challenge, so I decided to give it a spin.
打开替换菜单,填写([^ \\\
,并在替换为框中输入
] * \\\
)[^ \\\
] * \ n $ 1
然后为搜索模式选择正则表达式,单击全部替换,每隔一行删除。
Open the replace menu, fill in ([^\n]*\n)[^\n]*\n
in the "Find what" box and $1
in the "Replace with" box. Then select regular expression for the search mode, click replace all and every second line is deleted.
如果你想做类似的事情,你可以构建类似的正则表达式。例如,(([^ \\\
将替换每第n行将
] * \\\
){a})[^ \\\
] * \\\
替换为n-1和
[^ \\\
] * \\\
([^ \\\
] * \\\
) code>会让你保持偶数行,而不是奇数。
You can build similar regexes if you want to do something similar. For example, (([^\n]*\n){a})[^\n]*\n
will replace every nth line if you replace a
by n - 1 and [^\n]*\n([^\n]*\n)
will let you keep even lines instead of odd ones.
(这并不困难 - 我只需要更新我的过时的记事本++安装。)
(That wasn't hard at all - all I had to do was update my outdated Notepad++ installation.)
这篇关于删除notepad ++中的每隔一行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!