Reg expression to change characters within brackets '[ ]' to uppercase?
I’m having trouble coming up with a reg expression for the replace option for the following scenario:
Would like to replace all lowercase characters with brackets to uppercase.
i.e. array[enum1_name] becomes array[ENUM1_NAME].
I’ll defer to the reg expression experts out there.
Finds everything between
], inclusive, saving the stuff between the brackets as
\Esay to make everything between those two escapes uppercase. Thus
\U$1\Euppercases everything in
EDIT: that assumes you don’t have nested brackets, like
outer[ inner[ ENUM_HERE ] ]. If you do, you’ll have to define some rules for what’s allowed and what isn’t, and what needs capitalizing and what doesn’t.
Thanks so much! Worked like a champ! Over 750 replacements in one file alone. What a time saver.
Ah, already solved, nice :-)) So, just for fun, an other formulation could be :
Note, Kurt, that the two search regexes, from Peter and me, would match a “multi-lines” square-bracket block, too, as, for instance :
Thus, to restrict to a single-line square-bracket block, the Peter's search regex should be changed into :
And mine should be written :
Note that replacement case operations occur, only, with classical letters in range
[A-Za-z]Unfortunately, for Non English-American people, this does not work, at all, for accentuated letters :-((