JuJoDi
JuJoDi

Reputation: 14965

(REGEX) Regular Expression to replace all in Xcode 5

I have about 1,300 instances of

#import <xxxxx/ClassName.h>

that I'd like to replace with

#import "ClassName.h"

I noticed if I use the cmd-shift-f menu I can go to Replace > Regular Expression. The ClassName is not unique, xxxxx is always the same.

What is the regular expression that will replace all of those?

Upvotes: 6

Views: 2653

Answers (1)

acdcjunior
acdcjunior

Reputation: 135752

In Xcode 5:

As Find string:

#import <xxxxx/(\w+\.h)>

As Replace string:

#import "\1"


In Xcode 6:

Note: The behavior changed in Xcode 6. The \1 syntax was replaced with $1. Also keep in mind that newlines can now be matched in regular expressions, so make sure to skim before doing a Replace All.

Upvotes: 13

Related Questions