BBEdit: Regular Expression Case Change Options

I’m a huge fan of Regular Expressions. They are, without a doubt, the single most powerful tool in the programmer’s toolbox. BBEdit, my favorite text editor, happens to have really excellent regular expression support. Among its features is the ability to change the case of matched text – which is really great if you’re having to reformat lists or, say, rename every function in your code.

Here’s how it works. You write your usual regular expression in the Find window. In the Replace box, you prepend the normal replacement tag (\1, \2, etc) with a key character which transforms the following match. Here’s a list of available transformations:

Make the next character uppercase
Make all following characters uppercase until reaching another case specifier (\u, \L, \l ) or \E
\l (lowercase L)
Make the next character lowercase
Make all following characters lowercase until reaching another case specifier (\u, \U, \l ) or \E
End case transformation opened by \U or \L

So, a match would look like:

This is UPPERCASE: \U\1\E, this is camelCase: \L\1\E\u\2