如何删除 Notepad++ 中包含连字符、数字和特定 TLD 的行

时间:2021-05-26 09:20:33

标签: notepad++

我有一个包含域名的 txt 文件。

asd.com
ass.net
sdf.info
as-er.net
019-ne.com
012.com
01dc.net    

我想要这些

asd.com

首先,无论扩展名如何,我都想删除带有连字符、数字的行。 我不想删除 .com 行。我想删除 .net、.org、.info 等行而且如果一行中有连字符或数字,.com 也可以删除,否则我不想删除 .com 行我只想收集 .com 行不要有笨蛋和连字符

我如何用 Notepad++ 做到这一点

谢谢

1 个答案:

答案 0 :(得分:0)

您可以在正则表达式模式下尝试以下查找和替换:

Find:    ^(?:.*(?!\.com)\.\w+|.*[0-9-].*)\R
Replace: (empty)

opacity parameter

这里是正则表达式模式的解释:

^                     from the start of the line
(?:                   match EITHER of the following two patterns
    .*(?!\.com)\.\w+  match anything NOT ending in .com
    |                 OR
    .*[0-9-].*        match anything which has a digit or hyphen
)
\R                    OS independent line ending