Preston
Preston

Reputation: 1059

What is the "wildcard character"?

What character would act as a wild card in Objective-C? I have tried using *, but no luck. I am trying to get a value that is passed through a URL like this:

NSString *clearQuery = [query stringByReplacingOccurrencesOfString:@"q=set&mode=*&session=" withString:@""];

I need it to return only the session value. The mode could be a lot of things. Thanks for the help.

Upvotes: 0

Views: 974

Answers (2)

Nicholas Riley
Nicholas Riley

Reputation: 44331

Use NSRegularExpression or rangeOfString:... with NSRegularExpressionSearch instead. -[NSString stringByReplacingOccurrencesOfString:] matches literal strings, not patterns of any sort.

Upvotes: 2

Eiko
Eiko

Reputation: 25632

There is no such wildcard.

You might look into the new NSRegularExpression class, but this needs 4.0 at minimum.

Upvotes: 0

Related Questions