NSRegularExpression检测破折号

正则表达式:

static inline NSRegularExpression * AuthorRegularExpression() {
    if (!__authorRegularExpression) {
        __authorRegularExpression = [[NSRegularExpression alloc] initWithPattern:@"-\\s*(.)*$" options:NSRegularExpressionCaseInsensitive error:nil];
    }

    return __authorRegularExpression;
}

用来检测破折号(-),但是现在我将破折号格式改为em-dash。然后字符串就变成:

 NSString *dashAuthor = [NSString stringWithFormat:@"%C %@", 0x2014, self.theme.quoteAuthor];

应该怎么修改正则表达式来映射这个?这样可以搜索到作者名后面带有em-dash的。

你可以通过em-dash的Unicode 值: (\u2014 进行匹配,也可以用字符名:比如 \N{EM DASH} 进行匹配。