Xcode: Find and Replace does not handle regexes capture groups

Originator:guillaume.algis
Number:rdar://32675379 Date Originated:2017-06-09
Status:Duplicate of 32039812 Resolved:
Product:Xcode Product Version:9.0 beta (9M136h)
Classification:Suggestion Reproducible:Always
 
Summary:
When using the Find and Replace feature of Xcode (Find > Find and Replace...), one cannot use regex capture groups to reference a part of the matched expression in the replacement string.

Steps to Reproduce:
1. Open a source file
2. Open the Find and Replace view (Find > Find and Replace)
3. Select the regex find mode (how to varies depending on the Xcode version you're using)
4. Type a regex with capture groups in the Find text field. eg. `@property int (.+?);`
5. Type a replacement string with references to the capture groups in the Replace text field. eg. `@property double \1;`

Expected Results:
The reference to the capture group (`\1`) gets expanded to the part of the string matched by the regex's capture group.

So, for example:
@property int foobar;

will become after replacement:
@property double foobar;

Observed Results:
References do not get expanded.

So, for example:
@property int foobar;

will become after replacement:
@property double \1;

Version:
Xcode 8.3.x
Xcode 9.0 beta (9M136h)

Notes:
According to this blog post, this used to work (?) : http://roadfiresoftware.com/2013/12/replacing-regular-expressions-in-an-xcode-project/

Configuration:

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!