Reputation: 19
I'm looking for a way to capitalize the first letter of each word but exclude some words like 'of' 'the' 'from' and such.
Can it be done with notepad++?
Upvotes: 1
Views: 147
Reputation: 1069
Although, you asked explicitly for Notepad++, it is sometime nice to see alternatives. I can recommend you text editors with multi cursor support like Sublime Text, Atom or VS Code.
Then your question can be solved very elegantly.
The first step is to select all words. So search for [a-z]+
. Then place one cursor on each word. In Sublime Text for example you can do this with Alt+Enter. Then you can search within this selection for about|from|the|of|to|a
.
Now you have all these words selected simultaneously. Press Ctrl+C to copy them all to clipboard.
When this is done search again for [a-z]+
. Once you have each word selected, press cursor left, shift+right in order to mark the very first letter of each word. Go to the menu and execute the command "to upper case".
Now you are nearly done. You only must bring back the contents from the clipboard. So search again for [a-z]+
, then for about|from|the|of|to|a
. And then press Ctrl+V.
That is all. It is extremely comfortable with multi cursor mode.
This has a few disadvantages. The performance is poor if you have more than thousand words. The steps are not so quickly to be reproduced if have to do it more often. But with multiple cursor editing, everything is always intuitive. You don't need sophisticated regular expressions and no expert skills. This may be the reason why the text editors that are mentioned above became so popular over the last years.
Upvotes: 0
Reputation: 350147
Yes, it can be done with find & replace Ctrl+H:
Find what: \b(?!(?:about|from|the|of|to|a)\b)([a-z])
Replace with: \U\1
☑ Match case
Search mode:
⦿ Regular expression ☐ .
matches newline
Replace All
You'll get the point where to add more of the words that should not be touched...
Upvotes: 2