Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

(REGEX) Regular Expression to replace all in Xcode 5

Tags:

regex

xcode5

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?

like image 423
JuJoDi Avatar asked Oct 11 '13 17:10

JuJoDi


1 Answers

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.

like image 76
acdcjunior Avatar answered Nov 14 '22 22:11

acdcjunior



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!