【发布时间】:2013-04-21 06:54:55
【问题描述】:
我有这个字符串:
NSString* yourString = @"(;GM[1]FF[4]SZ[19]AP[CGoban Pro:2.2]PW[Michael Redmond]WR[9p]DT[2010-12-12]KM[6.5]RE[B+0.5]AN[Michael Redmond]BK[1]C[toto : [test]]";
我有这个正则表达式:
NSRegularExpression* regex = [NSRegularExpression
regularExpressionWithPattern:@"((RU)|(KM)|(TM)|(OT)|(PW)|(PB)|(WR)|(BR)|(WR)|(DT)|(RE))\\[[\\w ]+\\]"
options:NSRegularExpressionCaseInsensitive
error:&error];
我不能用 \w 和 \ 获得数值。或仅 .什么都不退! 谁能帮帮我?
谢谢
【问题讨论】:
-
您期望的结果是什么,您实际得到了什么?此外,如果您展示了如何使用正则表达式对象,那将会很有帮助。
-
为我工作。我得到匹配“PW[Michael Redmond]”和“WR[9p]”。您是否还尝试捕获“KM[6.5]”或“DT[2010-12-12]”?
-
是的。我有带有 \\w 的常规文本,但我没有 6.5 或 2010-12-12。我怎样才能得到所有这些?
标签: objective-c regex nsstring numeric nsregularexpression