Alex Gray
Alex Gray

Reputation: 16463

How to use regex "named matches" in Xcode's "Search and Replace"?

I'm used to regular expression syntax which allows for “named matches” from the search string to be used in the construction of the replacement term. For example…

@property (strong) NSWindow *window; ➜  @pr.*\*  
➜ @property (strong) NSWindow 

or

@property (strong) NSWindow *window; ➜  @pr.*\*(.*) ➜    
$1 ➜ window;

Ya, know… the first set of (…) is $1, second (…) is $2, etc…

Xcode does match the search string… but how can I filter the query string / pass the result to... the "Replace" portion of Xcode's "Search and Replace" function?

Regex matches dont seem to work in xcode.

Upvotes: 1

Views: 549

Answers (1)

Itai Ferber
Itai Ferber

Reputation: 29833

Use a backslash instead of a dollar sign. \1 matches the first group, and so on.

Upvotes: 1

Related Questions