What is the "wildcard character"?
What character would开发者_Python百科 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.
Use NSRegularExpression or rangeOfString:...
with NSRegularExpressionSearch
instead. -[NSString stringByReplacingOccurrencesOfString:]
matches literal strings, not patterns of any sort.
There is no such wildcard.
You might look into the new NSRegularExpression
class, but this needs 4.0 at minimum.
精彩评论