Reputation: 1
Using Vs Code I would like to replace every 2nd uppercase letter in a word to the matching lowercase one only if the first 2 letters of the word are uppercase.
Example: LEtter
would become Letter
, but iOS
, US
or DNA
would remain unchanged.
I figured using regular expressions and use the replace feature: the appropriate search string to use could be \s[A-Z][A-Z][a-z]
(but probably this one doesn't work if I want to use it to replace stuff?). However, I don't know how to replace the 2nd letter then.
I am grateful for suggestions!
Upvotes: 0
Views: 660
Reputation: 28633
You can use the following regular expression Find/Replace with Match Case (Aa
button)
Find: \b([A-Z])([A-Z])([a-z]+)\b
Replace: $1\l$2$3
In front of the $2
is a lowercase L
Group each part and convert the second capture group to lower case.
Upvotes: 2