NSRegularExpression:如何匹配XXX ... YYY?

时间:2014-04-11 13:36:47

标签: regex cocoa nsregularexpression

我试过了

[[[NSRegularExpression alloc] initWithPattern:@"XXX(.*)ZZZ" options:0 error:NULL]

但它不起作用。

我希望通过两个标记XXXZZZ匹配任意字符序列。

1 个答案:

答案 0 :(得分:0)

答案是......如果你想匹配任何字符序列,请不要忘记NSRegularExpressionDotMatchesLineSeparators

     [[[NSRegularExpression alloc] initWithPattern:@"XXX(.*)ZZZ" 
                       options:NSRegularExpressionDotMatchesLineSeparators 
                                             error:NULL]
相关问题