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

  • SEARCH
  • Home
  • 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 8858713
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T14:53:26+00:00 2026-06-14T14:53:26+00:00

So I receive an NSString with html code like this: <p class=img><img src=blahblahblah></p><p>This is

  • 0

So I receive an NSString with html code like this:

<p class="img"><img src="blahblahblah"></p><p>This is some text</p>

I would like to find the end of the img-classed paragraph, so I can insert a heading in between the two paragraphs. Please note:

  • that the img-classed paragraph is not necessarily the first paragraph in the string.
  • there can be multiple img-classed paragraphs in the string but I only need to insert something after the first one

I would like to find the character-position after the first img-classed </p> in the string, and not parse it.

  • 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-06-14T14:53:28+00:00Added an answer on June 14, 2026 at 2:53 pm

    You want to parse, there is really no other option. But then make sure to find a criteria which is really unique.

    Here is the Cocoa+NSString solution :

                NSScanner *scanner = [NSScanner scannerWithString:originalString];
    
    
                [scanner scanUpToString:@"<p class=\"img">" intoString:nil];
                [scanner scanString:@"par_categorie_2\">" intoString:nil];
    
                [scanner scanUpToString:@"</p>" intoString:nil];
                [scanner scanString:@"</p>" intoString:nil];
    
                NSInteger insertionPoint = scanner.scanLocation;
    
                NSMutableString *modifiedString = [[NSMutableString alloc] initWithString:originalString];
                [modifiedString insertString:insertedString atIndex:insertionPoint];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When my app gets to this, I receive EXC_BAD_ACCESS NSString *nameData = nameTextField.text; NSString
I have this class - (void) initWithFrame:(CGRect)frame withString:(NSString *)html{ //CGRect rectFrame = [UIScreen mainScreen].applicationFrame;
I receive a dictionary as input, and would like to to return a dictionary
I would like to draw the content of a NSString variable in a UIImage
I have two entities in coredata: Voice described like: NSString *code NSString *description and
I'm new with Cocoa and XCode, I would like to receive your help. I
I receive two strings: from=12:30 and to=14:30 which are two NSString objects. I'd like
In my code, I've customized the initWithNibName to receive some data it needs to
I have an html string that I've received from UIWebView from this call: NSString
I receive this error when I click on the section of my Tab-Bar application

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.