您好我有问题为我需要的结果创建正确的正则表达式。我到处寻找并亲自尝试,但我遇到了困难,这就是我现在得到的。
NSString *searchText = @"{ 124.0, 0.90, 0.556 } { 127.9, 0.9764, 0.456 }";
NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:@"\\{(.+\\d+[\\.]\\d+.+)\\}" options:0 error:nil];
NSArray *matches = [regex matchesInString:searchText
options:0
range:NSMakeRange(0, searchText.length)];
for (NSTextCheckingResult *r in matches)
{
NSRange numberRange = [r rangeAtIndex:1];
NSLog(@"%@", [searchText substringWithRange:numberRange]);
}
result
124.0, 0.90, 0.556 } { 127.9, 0.9764, 0.456
instead off 2 times a numberRange without curlybraces
124.0, 0.90, 0.556
127.9, 0.9764, 0.456
所以我希望有人可以帮助我,谢谢先进的
答案 0 :(得分:1)
regEx可以更简单,<font face='HelveticaNeue-bold' color='#4671A5' font size='6' style='position:absolute;z-index:500;width:100%;top:120px;vertical-align:middle;'>
<center>" . $row["username"]. " <div class='" . $row["status"]. "'></div>
<style>
.official {
content: url('http://bithumor.co/1234567890.png');
width: 28px;
height: 28px;
display: inline;
z-index:999999;
position: absolute;
vertical-align:middle;
}
</style>
和{
内的任何内容。
}
124.0,0.90,0.556
127.9,0.9764,0.456