How to change case of regex matching groups in the Rename dialog?

Let’s consider the following layer name: Button/light.

Now, using regular expressions, which would be (.+\/)(\w)(.+), how do I capitalize the second word?

Rebuilding without changes would be $1$2$3, but how do I make $2 to be uppercase? I thought it would be something like \U$2 like some languages do, but it doesn’t seem to work in the dialog.

1 Like

Hello there and welcome to the forum :waving_hand:

Unfortunately there’s no way to transform the case of regex capture groups in the “Rename All” dialog.

The good news though is there’s nothing we can’t do with Sketch plugins and a bit of magic :magic_wand::sparkles::

Say, you have a regex (.+) that captures the entire layer name as a single group ($1). Here’re the new options available in the pattern field:

Input Template Output Description
“Rectangle” $1 “Rectangle” The original behavior, no changes here
“Rectangle” $^1 “RECTANGLE” Makes the entire capture group uppercased
“Rectangle” $.1 “rectangle” Makes the entire capture group lowercased
“my layer” $-1 “My Layer” Capitalizes the entire capture group

Download this plugin here :backhand_index_pointing_right: Releases · rodionovd/renamelayers-regex-mod-sketchplugin · GitHub

Tested to work on Sketch 101.9 and 2025.1 (Beta) but I could easily overlook a scenario or two where it doesn’t – let me know if you find a bug!

1 Like