我正在做一個正則表達式以下行:NSRegularExpression不匹配
Table 'Joella VIII' 6-max Seat #4 is the button
到目前爲止,我有這樣的:
self.tableDetailsRegex = [NSRegularExpression regularExpressionWithPattern:@"Table '[A-Za-z0-9 ]*' [0-9]+-max Seat #[0-9]+ is the button" options:NSRegularExpressionAllowCommentsAndWhitespace error:nil];
if([self.tableDetailsRegex numberOfMatchesInString:line options:NSMatchingReportCompletion range:NSMakeRange(0, line.length)] == 1)
{
NSLog(@"%@", line);
}
所以,我的正則表達式爲:
Table '[A-Za-z0-9 ]*' [0-9]+-max Seat #[0-9]+ is the button
而且我敢肯定,所選線路在某些時候來的,因爲我打印所有行遠一點在我的代碼...
FWIW,如果我複製/粘貼您的模式和測試字符串到我的工具,它確實匹配。相對於「if」的問題? – Seki