\r\nThis PM was sent by [ helloworld ] [email protected],\r\nMembership Status : Non-Verified Member\r\nhttp://www.gg.com/A/F/U.asp?UserID=helloworld@1\r\n\r\n\r\n\r\n\r\n\r\nHi, may i know does the item still available?\r\n\r\n\r\n\r\n *** This email was sent using www.gg.com***
NSString *regexStr = @"@1(.*?)[\\*]";
NSError *error;
NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:regexStr options:NSRegularExpressionCaseInsensitive error:&error];
NSArray *matches = [regex matchesInString:message options:NSMatchingReportCompletion range:NSMakeRange(0, [message length])];
if ([matches count] > 0) {
for (NSTextCheckingResult *match in matches) {
NSString* matchText = [message substringWithRange:[match range]];
NSLog(@"match: %@", matchText);
NSRange group1 = [match rangeAtIndex:1];
NSLog(@"group1: %@", [message substringWithRange:group1]);
}
}
我希望得到“你好,我可以知道确实仍然可用的项目?”从字符串上述目标C
这应该工作。
NSString *regexStr = @"@1(.*?)\\*";
还使用NSRegularExpressionDotMatchesLineSeparators
选项。