开发者

about RegexKitLite linebreak

I'm use RegexKitLite to match some texts:

xxx*[abc]*xxx

and I want to match [abc],and use this regular:

NSString *result = [@"xxx[abc]xxx" stringByMatching:@"\\[(.*)?\\]" capture:1];

then, the result is [abc].But, if have linebreak in there:

xxx[ab c]xxx

It's dosen't wo开发者_运维知识库rk. I use ([\s\S]*), also dosen't math [abc]. How can I match this text? thank you


The . does not match new lines by default. You could use

 ... stringByMatching:@"(?s:\\[(.*)?\\])" ...
//                      ^^^^           ^

or supply the RKLDotAll option with the -stringByMatching:options:inRange:capture:error: method.

Alternatively, you could use the greedy variant

@"\\[([^\\]]*)\\]"   // \[  (  [ ^\] ]  )   \]
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜