像这样的东西会起作用。如果消息的这些部分也是动态的,您可能需要调整 fromString 和 toString,但这会让您开始。
NSString *someString = @"<script>p(34,'1','hello world');</script>/r/n";
NSString *fromString = @"<script>p(34,'1','";
NSRange fromRange = [someString rangeOfString:fromString];
NSString *toString = @"');</script>/r/n";
NSRange toRange = [someString rangeOfString:toString];
NSRange range = NSMakeRange(fromRange.location + fromRange.length, toRange.location - (fromRange.location + fromRange.length));
NSString *result = [someString substringWithRange:range];