# How to use regular expression find and replace to change the case of a letter

I'm looking to convert

\item helicopter

\item airplane

etc to

\item Helicopter

\item Airplane

etc.

Looking around the web it seems like I should be finding

(\\item) ([a-z])

and replacing with

\1 \U2

which should signify that the second backreference is to be replace with an upper-case version of the same letter, but it's not working. It's just replacing it with "\item \U2elicopter".

Any ideas?

I'm using MikTex with TexStudio

Cheers

• you have tagged this with l3regex but I think you want to do this as an edit to the source so it's a texstudio question not a tex one, can you confirm? Apr 29, 2020 at 13:28
• use ctrl+H for find and replace Apr 29, 2020 at 13:36
• Hey David, yeah I tried to just tag it as regex but it wouldn't let me. I'm new to stackexchange so not entirely sure how it works, sorry. Yeah, I'm trying to edit the source. Apr 29, 2020 at 13:56
• Not all regular expression systems support backrefs or case change functions I don't have texstudio so I can't tell you if they do (otherwise the syntax should probably be \U\2) but there are plenty of texstudio users here someone will tell you. Apr 29, 2020 at 14:08
• When I tried that it just replaces it with "\U" followed by backref 2. I guess it just doesn't support it in that case. Ah well, thanks anyway. Apr 29, 2020 at 14:46

Since this is something you will not have to do often, I would imagine it is okay to switch to another editor that does support it for this operation, like Notepad++. Note that the exact syntax for regular expressions may differ a bit from editor to editor. Here is an overview of the different conventions. Notepad++ uses the Boost regular expression engine, so both \1 \u\2 and \1 \U\2 work (where \u replaces only the first letter of the match and \U the entire match, which is the same for your expression).