6

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?

1 Answer 1

13

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.

Sign up to request clarification or add additional context in comments.

2 Comments

if you are looking for an answer that works in xcode6 you'll find it here stackoverflow.com/a/15208449/416184 basically you have to write $1 instead of \1
Damn Xcode 6 changing the syntax, took me a while to find the solution, thank you sir.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.