7

I'm having problems using the Find and Replace with Wildcards in Xcode. I found this post here: Xcode Wildcard characters?

However it is not working for me I'm thinking because of the older version of Xcode. I'm trying to find instances like these 3 different lines:

playerCardThirteenSlot = 6;
playerCardThirteenSlot = 7;
playerCardThirteenSlot = 8;

and in the find field am using

playerCardThirteenSlot = ([0-9]+);

which is not working. I just want to replace it with a blank string.

Can anyone help? Thanks!

Community
  • 1
  • 1
Ryan Caskey
  • 217
  • 1
  • 8

1 Answers1

7

You need to set Regular expression mode
Step 1:

Step 2:

Enter the regular expression:

The selected text:

If part of what is being searched for includes regular expression special characters they must be escaped.
String to match for different last digits:

if ([compCardThirteenTitle isEqualToString:[compHandNamesArray objectAtIndex:12]])
if ([compCardThirteenTitle isEqualToString:[compHandNamesArray objectAtIndex:13]])
if ([compCardThirteenTitle isEqualToString:[compHandNamesArray objectAtIndex:14]])

Regular expression to match:

if \(\[compCardThirteenTitle isEqualToString:\[compHandNamesArray objectAtIndex:1[2-4]\]\]\)
zaph
  • 111,848
  • 21
  • 189
  • 228
  • Thanks, I think my problem is that I am not searching for a regular expression, is there a work around if I want to search for something like: if ([compCardThirteenTitle isEqualToString:[compHandNamesArray objectAtIndex:12]]) … and then find all the numbers at objectAtIndex? – Ryan Caskey Jan 07 '14 at 20:57
  • I'm really just trying to do erase a bunch of code. I started the app with 15 "cards" and want to reduce it to 12. So I have been cutting lines like: if ([compCardThirteenTitle isEqualToString:[compHandNamesArray objectAtIndex:12]]) … because "compCardThirteenTitle doesn't exist anymore, however the objectAtIndex can vary so I'm looking to wipe all the lines at once. – Ryan Caskey Jan 07 '14 at 21:16