How do I change the first letter lowercase to uppercase in notepad++?
-
I want to change all first letters from lowercase to uppercase inside square brackets in notepad++, for example from [gasps] to [Gasps]. But if it is the characters name inside square brackets, make all caps.
This is what i have done and the outcome.


-
@Mohamed-Mohamed You were close to what is needed. The
[and]characters are special in the search part of a regular expression and so you need to put a\in front of them.It’s not clear though if you want just the first letter or the entire thing inside the
[ ... ]to be capitals.If the first letter then use
Search for:[([a-z]+)]
Replace with:[\u\1]If the entire word then use
[\U\1]with a capital ‘U’ instead of lower case ‘u’ in the replace part.See https://npp-user-manual.org/docs/searching/#substitutions for how the
\uand\Uwork in the replacement part of a regular expression.It’s also not clear if you want
[Explosion]to become[EXPLOSION]. As you have match-case enabled the search for[a-z]would not match a capital ‘E’. If you want[EXPLOSION]then you can either turn the match-case tick box off or you can preface the search part with(?i)to ignore case (Search for(?i)[([a-z]+)]) or you can search for[([A-Za-z]+)]In https://npp-user-manual.org/docs/searching/#regular-expressions there are various\followed by a letter things you can use to search for letters, lower case letters, etc. Use whatever you feel comfortable with. -
@mkupper Thank you it worked, but is it possible to make all characters names be capslock e.g. [JOHN].
-
@Mohamed-Mohamed
You’d need a|-separated list of all the characters’ names.For example, if the characters are named
John Bob Mary Ellen Fredyour regex becomes
(?i)\\[(?:(John|Bob|Mary|Ellen|Fred)|([a-z]+))\\]
and your replacement becomes[(?1\U${1}\E:(?2\u${2}))]
Thus, you would convert[explosion] [crash] [john] yo dawg [Ellen] i herd u like regex [bob] so i made regex [boom] [pow] [mary] so u can regex [zap] [fred] with regexinto
[Explosion] [Crash] [JOHN] yo dawg [ELLEN] i herd u like regex [BOB] so i made regex [Boom] [Pow] [MARY] so u can regex [Zap] [FRED] with regex