次の式を検出しようとしています:$
例えば
$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];