Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert first lowercase to uppercase and uppercase to lowercase (regex?)

I have a huge file in this layout:

world12345:Betaalpha    
world12344:alphabeta    
world12343:ZetaBeta    
world12342:!betatheta

I need to convert the first lowercase letter after the ":" to uppercase and the first uppercase letter to lowercase. I've tried using notepad++ and emeditor, but I'm not that experienced with regex.

This is how I want it to become after (regex?)

world12345:betaalpha    
world12344:Alphabeta    
world12343:zetaBeta    
world12342:!betatheta   (unchanged, as the first char is a special char)

I have tried searching the web for a regex in npp+, but to no avail. Unfortunately, I'm not a scripter so I can't write one myself.

Thanks in advance!

like image 246
marnix409 Avatar asked Feb 01 '26 23:02

marnix409


1 Answers

This is the simplest solution I could come up with.

Find what: :(\u)|:(\l)

Replace with: :\l($1)\u($2)

Enable the settings: Wrap Around & Match case

Search mode: Regular expression

Press Replace All.

Explanation

\u matches & converts uppercase, \l matches & converts lowercase.

enter image description here

like image 117
J.A.P Avatar answered Feb 03 '26 15:02

J.A.P



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!