开发者

What is the "wildcard character"?

开发者 https://www.devze.com 2023-01-29 12:34 出处:网络
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:

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消