NSRegularExpression
大文字と小文字を区別して検索するように指定する方法はありますか? 以下のテキストの大文字のタグ「ACL」と一致させようとしています。私が使用しているパターンは単純です:
// Pattern
[A-Z]+
// SearchText
<td align=\"left\" nowrap><font face=\"courier, monospace\" size=\"-1\">ACL*</font></td>
// Code:
NSString *textBuffer = @"<td align=\"left\" nowrap><font face=\"courier, monospace\" size=\"-1\">ACL*</font></td>";
NSString *pattern = @"([A-Z]+)";
NSRegularExpression *regExp = [NSRegularExpression regularExpressionWithPattern:pattern options:NSRegularExpressionCaseInsensitive error:nil];
NSTextCheckingResult *result = [regExp firstMatchInString:textBuffer options:0 range:NSMakeRange(0, [textBuffer length])];
NSLog(@"OBJECT CLASS: %@", [textBuffer substringWithRange:[result range]]);
出力: (case-Insensative を使用すると、最初の「td」が期待どおりに取得されますが、本当に必要なのは「ACL」です
私はそれNSRegularExpressionCaseInsensitive
が間違っていることを知っていNSRegularExpressionCaseSensitive
ます. ?(i)
また、大文字と小文字を区別しない検索を指定するflagOptionもありますが、大文字と小文字を区別するものはありません。私は何が欠けていますか?