任何人都可以帮助我在目标 c 中使用正则表达式和负十进制值。
			
			1117 次
		
1 回答
            2        
        
		
[NSRegularExpression regularExpressionWithPattern:@"(?:-|+)?\\d+(\\.\d+)?" options:0 error:NULL]
这就是人类认为的小数。但是编译器是不同的。
编辑:
- (BOOL)checkForSpecialChar:(NSString *) string
{
    static NSRegularExpression *regex = nil;
    if (regex == nil)
        regex = [[NSRegularExpression alloc] initWithPattern:@"(?:-|+)?\\d+(\\.\d+)?" options:0 error:NULL];
    NSRange fullRange = {0, [string length]};
    NSRange range = [regex rangeOfFirstMatchInString:string options:0 range:fullRange];
    return NSEqualRanges(fullRange, range);
}
于 2012-08-31T13:54:33.893   回答