Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can Find and Replace with WildCard Number in Xcode

Tags:

replace

xcode

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!

like image 1000
Ryan Caskey Avatar asked Jan 07 '14 20:01

Ryan Caskey


People also ask

Which symbol can represent a number of characters in a find and replace wildcard?

Alternatively referred to as a wild character or wildcard character, a wildcard is a symbol used to replace or represent one or more characters. The most common wildcards are the asterisk (*), which represents one or more characters and question mark (?) that represents a single character.

Which of the following wildcard character is used to replace a string of text in a search term?

Answer: The wildcard you're likely to use most frequently is the asterisk. It indicates that you want to search for any number of characters. For example, to search for all words beginning with “Th,” type “Th*” in the “Find What” box, and then click the “Find Next” button.


1 Answers

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]\]\]\)
like image 70
zaph Avatar answered Sep 28 '22 05:09

zaph