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?

JuJoDi
  • 14,627
  • 23
  • 80
  • 126

1 Answers1

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.

Community
  • 1
  • 1
acdcjunior
  • 132,397
  • 37
  • 331
  • 304
  • 2
    if you are looking for an answer that works in xcode6 you'll find it here http://stackoverflow.com/a/15208449/416184 basically you have to write $1 instead of \1 – clauswey Oct 06 '14 at 11:25
  • Damn Xcode 6 changing the syntax, took me a while to find the solution, thank you sir. – user2387149 Jul 30 '15 at 09:03