Remove lines that is shorter than 5 characters bef

2019-08-11 19:07发布

问题:

Maybe the title is 99% not understandable

I have like that:

abc@5004428
abcd@62604
abcde@505779

But my file is larger than that.

So, I want to remove the whole line that contain "abc" and "abcd" becase they are before @ and they are shorter than 5 or not equal characters.

More explained: I want to remove the whole line which value before @ is shorter than or EQUAL to 5 characters.

Any help would be appreciated.

Thanks!

回答1:

You can use regex like this: ^(.{0,4}@.*)$ to select lines and then remove them with Notepad++.

^ - a start of the line

.{0,5} - checks if value before @ is shorter than or equal to 5 characters.

NOTE: .{0,4} will check if value before @ is shorter than 5 characters (not equal to 5 characters).

.* - all other symbols after @.

$ - an end of the line



回答2:

Set 'Search Mode' to regular expression, and use the following phrase:

^\w{1,5}@.+

works like this:

^- : start of line

\w{1,5} : 1 to 5 word charachters long

@ : matches 'At sign' literally

.+ : remainder of line

and replace with empty line. To replace empty lines set search mode to extended and replace double line ends with single line ends.