Remove lines that is shorter than or equal 5 characters after the : using Notepad++

杀马特。学长 韩版系。学妹 提交于 2019-12-20 06:27:26

问题


The question is like: Remove lines that is shorter than 5 characters before the @ using Notepad++

But it differs a bit...

I have like that:

abc:123

abc:1234

abc:12345

PLEASE NOTE: abc is not on all the lines, it is just an example.

I want to remove the first line in the previous example because 123 which is after : is shorter than or not equal to 5 characters.

Any help would be appreciated.

Thanks!


回答1:


Open Notepad++ find and replace choose regex mode in the search and place ^((?!.+:\d{5,}).)*$ in search and keep replace with blank and press replaceAll

^((?!.+:\d{5,}).)*$




回答2:


Without knowing the language there is only so much help I can offer. I'll give you an example of how I would solve this problem in C#.

Start by creating a string for your updated file (without the short lines)

string content = "";

Read a line in from your file. Then get a substring of the line you read in - the abc: portion and check the length.

line = line.substring(indexof(":"), length - indexof(":"))
if(line.length > 5)
{
  content += line;
}

At the end, truncate your file and write content to it.



来源:https://stackoverflow.com/questions/50954452/remove-lines-that-is-shorter-than-or-equal-5-characters-after-the-using-notepa

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!