0

After looking across the internet for about an hour, I decided to register an account and ask a question :)

I'd like to remove all lines that don't contain at least one uppercase letter, lowercase letter, number and special symbol [Examples of Special Symbols: !@#$%^&*()] in Notepad++

Example Input:

josukeisbig
JOSUKEISBIG
JosukeIsBig
JosukeIsB1g
JosukeIsB1g!

Example Output:

JosukeIsB1g!

The only related thread I found was this: How to remove lines that not containing any uppercase letters or lowercase letters or numbers notepad++

But OP didn't specify special characters.

  • Thanks!
6
  • I believe this will answer your question - stackoverflow.com/questions/1559751/… Commented Feb 13, 2020 at 5:40
  • Zero Length match error? @Sergiu Elmi
    – shababpp
    Commented Feb 13, 2020 at 5:47
  • What do you mean? Commented Feb 13, 2020 at 5:53
  • In Notepad ++, it also returns lines without special characters through results. And replaces the results with ^ zero length match on a white background until you move onto the next one.
    – shababpp
    Commented Feb 13, 2020 at 5:57
  • @Sergiu Elmi ???
    – shababpp
    Commented Feb 13, 2020 at 6:05

2 Answers 2

0

You can use the below regexp:

^(?!(^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[\!\@\#\$\%\^\&\*\(\)\]]).+$)).*$

In Notepad++ you can either search for this regexp, replace all with an empty string and then go to:

Edit >> Line Operations >> Remove Empty Lines

As an alternative to delete them, instead of using Find & Replace, you can use the Mark tab from the same window and mark all lines using the same regexp. To delete them, go to:

Search >> Bookmark >> Remove Bookmarked Lines


A screenshot for convenience:

enter image description here

0
  • Ctrl+F
  • Select "Mark" tab
  • Find what: ^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[^\w\r\n]).+$
  • CHECK Match case
  • CHECK Wrap around
  • CHECK Regular expression
  • UNCHECK . matches newline
  • CHECK Bookmark line
  • Mark all

Explanation:

^                   #  beginning of line
  (?=.*[a-z])       # lookahead, make sure we have a lowercase
  (?=.*[A-Z])       # lookahead, make sure we have an uppercase
  (?=.*\d)          # lookahead, make sure we have a digit
  (?=.*[^\w\r\n])   # lookahead, make sure we have a non-word, non-linebreak
  .+                # 1 or more any character
$                   # end of line

Screenshot:

enter image description here


Second step:

Menu => Search => Bookmark => Remove Unmarked Lines.   

Screenshot:

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .