KDevelop: How to Find/Replace in multiple files using regex captures?

I want to replace some text and have the replacement reference a regex capture group. This works fine when replacing on a single file but with with the “Find/Replace in Files” dialog I get “Failed: Captures are not allowed in pattern strings”.
I think I need to use Template / Replacement Template for this but it isn’t really clear how they work.

1 Like

I found a solution, posting it here for posterity:

Pattern needs to be non-empty, but it doesn’t matter too much what’s in there.

Template can be a full regex with capture groups, %s will insert the Pattern in the regex.

Replacement pattern can stay as %s.

Replacement text can use the capture references (\1 etc) as you would expect.

Interestingly, there are some features that are supported by the single file replace that are not supported by Find/Replace in files (eg: \U...\E to make something upper case)