I have one very long string.
In it are markers and between those markers are text.
example:
<body>blah blah blah</body><body>another string</body>
basically I want to iterate through the string and extract the text in between the markers. additionally I want to place each string of text into a separate string.
So essentially I’d end up with:
string1:blah blah blah
string2:another string
How would I do this?
Edit – I may not have been clear. the one string will have many many delimiters of the same type in. so the input string could literally be:
<body>blah blah blah</body><body>another string</body><body>blah blah blah</body><body>another string</body><body>blah blah blah</body><body>another string</body><body>blah blah blah</body>
If first delimiter appears in your text only once, you may use code:
You may use NSScanner as well:
The second code snippet seems to be better.
If XML you try to parse gets more complicate it may turn to better to use NSXMLParser. But in such simple examples usage of NSXMLParser is too verbose.