NSString *taskTitleStyle = @"font-weight: bold; color: rgb(238, 236, 224); ";
NSError *error = NULL;
NSString *substringForFirstMatch;
NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:@"\\b(\\d)*\\,\\s(\\d)*\\,\\s(\\d)*\\b"
options:NSRegularExpressionCaseInsensitive
error:&error];
NSRange rangeOfFirstMatch = [regex rangeOfFirstMatchInString:taskTitleStyle options:0 range:NSMakeRange(0, [taskTitleStyle length])];
if (!NSEqualRanges(rangeOfFirstMatch, NSMakeRange(NSNotFound, 0))) {
substringForFirstMatch = [taskTitleStyle substringWithRange:rangeOfFirstMatch];
NSLog(@"%@", substringForFirstMatch);//打印238, 236, 224
}
NSArray *array = [substringForFirstMatch componentsSeparatedByString:@", "];
return [UIColor colorWithRed:[[array objectAtIndex:0] floatValue] / 255 green:[[array objectAtIndex:1] floatValue] / 255 blue:[[array objectAtIndex:2] floatValue] / 255 alpha:1];