Suppose I has the next text:
test
HELLO
help
HOW ARE YOU
buy
I need to get (filter) only text lines with all uppercase chars. So result must be like this:
HELLO
HOW ARE YOU
Suppose I has the next text:
test
HELLO
help
HOW ARE YOU
buy
I need to get (filter) only text lines with all uppercase chars. So result must be like this:
HELLO
HOW ARE YOU
There are two very useful interactive built-in functions flush-lines
and keep-lines
that take a regular expression as an argument that modify the current buffer.
Place the cursor before the lines you want to filter and run M-x keep-lines
with argument ^[A-Z ]+$
to get the result you want.
Do you want this? only-uppercase is used to test which item should be remove(t:leave, nil: remove). Then seq-filter to filter the input items.
(defun only-uppercase (str)
"only uppercase"
(if (numberp
(let ((case-fold-search nil))
(string-match-p "[a-z]" str)))
nil t))
(defun filter-uppercase ()
"filter uppercase"
(interactive)
(print
(seq-filter
'only-uppercase
(split-string
(buffer-substring-no-properties (region-beginning) (region-end))
"\n" t))))