Notepad++ how to extract only 1, 2, 3, 4 or 5 character capital lettered Words only in a document?

Solution 1:

  • Ctrl+H
  • Find what: ^([A-Z]{1,5})$|^.*\R?
  • Replace with: $1
  • CHECK Match case
  • CHECK Wrap around
  • CHECK Regular expression
  • UNCHECK . matches newline
  • Replace all

Explanation:

^               # beginning of line
    (               # start group 1
        [A-Z]{1,5}      # 1 up to 5 capital letters
    )               # end group
$               # end of line
  |               # OR
^               # beginning of line
    .*              # 0 or more any character but linebreak
    \R?             # any kind of linebreak (i.e. \r, \n, \r\n), optional

Replacement:

$1              # content of group 1, the capital letters

Screenshot (before):

enter image description here

Screenshot (after):

enter image description here