我正在尝试检测以下表达式:$
例如
$john
或者
$mike
我的正则表达式有什么问题?
//Check for $symbol
NSRegularExpression *symbolRegex = [[NSRegularExpression alloc] initWithPattern:@"($[a-zA-Z0-9_]+)"
options:NSRegularExpressionCaseInsensitive
error:nil];
matches = [symbolRegex matchesInString:labelText options:0 range:NSMakeRange(0, [labelText length])];
for (NSTextCheckingResult *result in matches) {
NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"symbol://%@",[labelText substringWithRange:result.range]]];
[bodyLabel addCustomLink:url inRange:[result range]];
}
[symbolRegex release];