I am trying to create a regex in Notepad++ to remove words except those enclosed between special characters. I am using this regex \<.*?\>
which removes the words along with text.
Eg:
Sample text
random text <ABCD> random text
random text <QWERT> random text
random text <XYZ> random text
Output
random text random text
random text random text
random text random text
I just want the opposite of the above regex
Eg:
Sample text
random text <ABCD> random text
random text <QWERT> random text
random text <XYZ> random text
Output
<ABCD>
<QWERT>
<XYZ>
This is a job for (*SKIP)(*FAIL)
verbs.
<.+?>(*SKIP)(*FAIL)|.+?
LEAVE EMPTY
. matches newline
Explanation:
<.+?> # matches the string to be kept
(*SKIP) # skip this match
(*FAIL) # considere it failed
| # OR
.+? # match any character but newline
Screenshot (before):
Screenshot (after):