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!
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
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$1because 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
\Uwhich says “output everything after here in upper case unless you stop this with an\E“. Then$1writes back what we matched with\S+(in your caseterm). 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:
But without actual input examples, I am afraid you have to figure out the proper search pattern yourself.