Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7053311
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T03:29:23+00:00 2026-05-28T03:29:23+00:00

I have one very long string. In it are markers and between those markers

  • 0

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>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T03:29:23+00:00Added an answer on May 28, 2026 at 3:29 am

    If first delimiter appears in your text only once, you may use code:

    NSArray *c1 = [text componentsSeparatedByString:@"<body>"];
    if ([c1 count]<2) {
        // you don't have first delimiter
    }
    NSArray *c2 = [[c1 objectAtIndex:1] componentsSeparatedByString:@"</body>"];
    if ([c2 count]<2) {
        // you don't have second delimiter
    }
    NSString *result = [c2 objectAtIndex:0];
    

    You may use NSScanner as well:

    NSScanner *scanner = [NSScanner scannerWithString:text];
    if (![scanner scanUpToString:@"<body>" intoString:nil]) {
        // there is no opening tag
    }
    NSString *result = nil;
    if (![scanner scanUpToString:@"</body>" intoString:&result]) {
        // there is no closing tag
    }
    

    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.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an xml string which is very long in one line. I would
I have a text file that contains very long lines. I need one piece
Say for example I have the following code: <h3>My very long title</h3> <h3>Another long
I have one very general object that I want to map to a destination
I have a very simple class with only one field member (e.g. String). Is
I have a very long list of dictionaries with string indices and integer values.
I have some text which occasionally contains very long strings of characters, which is
I have a textbox to display a very long Base64 string. The TextBox.Multline =
I have two linkedlists A1 and A2, both contain very long strings. I want
I'm developing in Java and I have a long string of text which contains

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.