Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/42.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 预测用途_Iphone - Fatal编程技术网

Iphone 预测用途

Iphone 预测用途,iphone,Iphone,我正在使用字符串@“King(+$100)”。我想使用NSPredicate查找字符串是否有(+$[0-9]*)。因此如何使用NSPredicate请尝试以下方法: // The string to evaluate NSString *string = @"King (+$100)"; // The regular expression NSString *regExp = @".*\\(\\+\\$[0-9]*\\).*"; NSPredicate *predicate = [NSPre

我正在使用字符串@“King(+$100)”。我想使用NSPredicate查找字符串是否有(+$[0-9]*)。因此如何使用NSPredicate请尝试以下方法:

// The string to evaluate
NSString *string = @"King (+$100)";

// The regular expression
NSString *regExp =  @".*\\(\\+\\$[0-9]*\\).*";
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"SELF MATCHES %@",regExp];

// Test if the object checks the regular expression 
BOOL ok = [predicate evaluateWithObject:string];
有关NSPredicate的所有文档,请参阅:

我不明白你的问题。你想确定数字0-9是否在一个字符串中?谢谢。我知道了。还有一件事是如何得到那个特定的字符串。如果模式匹配,即[predicate evaluateWithObject:string];如果这个函数retuns为true,那么使用NSPredicate(+$100)就有办法获得它。我不知道如何使用标准API实现这一点。我已经找过了,但什么都没有。。。因此,我想您必须使用NSString和/或NSScanner来查找您的事件。