For example, there is a lot of lines like this: "term - definition". As regular expressions in Notepad ++ can be done to the "term" was written in uppercase (capital) letters - TERM?
Thanks!
You can also use Ctrl+Shift+U for UPPERCASE and Ctrl+U for lowercase if you like shortcut keys.
To use a keyboard shortcut to change between lowercase, UPPERCASE, and Capitalize Each Word, select the text and press SHIFT + F3 until the case you want is applied.
Change case to Upper CaseHighlight the text and go to menu Edit–>Convert case. Select the Upper case option or use the keyword shortcut (Ctrl+Shift+U) to change the case of the text to upper case in Notepad++ that means all caps.
Find what: ^(\S+)(?=\s*-)
Replace with: \U$1
What does this do? The search pattern matches as many non-space characters at the beginning of a line as possible (\S+
) and captures them in variable $1
because of the parentheses. After that follows a lookahead that asserts that this "word" is followed by a hyphen (without anything else in between). This lookahead is not actually included in the match, so it won't be removed/replaced.
The replacement starts with \U
which says "output everything after here in upper case unless you stop this with an \E
". Then $1
writes back what we matched with \S+
(in your case term
). But in upper case.
Make sure to update to Notepad++ 6. Before that regular expressions were a bit quirky.
Here is the documentation of what's possible in the replacement string.
EDIT:
I guess your actual lines might be a bit more interesting than just having one word at the beginning of the line and then the hyphen. But from your given example I can't tell. But to do this for an arbitrary number of words and ignore whitespace at the beginning of the line (as long as there is an hyphen somewhere in the line), you could do something like this:
Find what: ^(([ \t]*[^\s-]+)*)(?=[ \t]*-)
But without actual input examples, I am afraid you have to figure out the proper search pattern yourself.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With