I have made up a simple set of web services (trying to make a super simple chat server) that return a string. I cannot figure out a easy way to phrase the string using the NSString class.
the string looks something like
start user
tedpottel
fred
Oreo
end user
start comments
hello today how are you
say whats up
end comments
I would like to
1. extract a separate nsstring from start user to end user and start comment to end comment
2. then extract each line by using /n as the start and begging.
I can only find methods to get all the text from the end to a index, or from the begging to a index. I did not see anything for extrcating a string between to strings, or something like mid in php (ahhhh I wish i was using php now).
Since there is code to phrase xml files, there must be a way to do this am I missing something??????
Ted
If you refer to the documentation for
NSStringhttp://developer.apple.com/library/ios/#documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/Reference/NSString.html, you’ll find a method calledsubstringWithRange:that will do what you seem to be asking for.If you want to do more sophisticated parsing, you should study
NSRegularExpressionhttp://developer.apple.com/library/ios/#documentation/Foundation/Reference/NSRegularExpression_Class/Reference/Reference.html.