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 8480901
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T19:25:15+00:00 2026-06-10T19:25:15+00:00

I need to replace the standard upper double quotes that already exist (in text

  • 0

I need to replace the standard upper double quotes “” that already exist (in text I get from a database) with specific quotes for german text for use in a UIWebView.
The first double quote character before the quoted word(s) (every even index) needs to be replaced with the HTML equivalent of „ which is „ and the second one after the quoted word(s) (every odd index) with “ which is “. The quotes can be anywhere in the text, so I can’t rely on any fixed positions.

So basically I have a NSString like this:

just “some” text with some “more” text

or in Objective-C:

NSString *str = @"just \"some\" text with some \"more\" text";

I am aware of the stringByReplacingOccurrencesOfString method from NSString, but of course this only replaces all double quotes with the bottom double quote mark.

NSString *newStr = [str stringByReplacingOccurrencesOfString:@"\"" withString:@"„"];

I couldn’t find a way to just replace every second or every n-th occurrence, does someone have a hint/idea how I could accomplish that?

Thanks a lot

  • 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-10T19:25:16+00:00Added an answer on June 10, 2026 at 7:25 pm

    NSScanner offers another option…

    NSScanner *scanner = [NSScanner scannerWithString:englishString];
    NSMutableString *germanString = [NSMutableString string];
    BOOL foundQuote = YES;
    int quoteIndex = 0;
    
    while (foundQuote) {
        NSString *nextPart = @"";
        [scanner scanUpToString:@"\"" intoString:&nextPart];
        if (nextPart != nil) {
            [germanString appendString:nextPart];
        }
        foundQuote = [scanner scanString:@"\"" intoString:nil];
        if (foundQuote) {
            [germanString appendString:((quoteIndex % 2) ? @"“" : @"„")];
            quoteIndex++;
        }
    }
    
    NSLog(@"The German version is: %@", germanString);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Need to replace a domain name on all the links on the page that
I need to replace some value in given text using c# preferably using regex
I need to replace the Bind event from JQuery with some event from JavaScript.
I have a SQL Table UDF That gets a Standard Deviation from a 20
Need to replace text bullet chars • with HTML ul & li tags within
I need to replace the standard Overflow function in a ToolStrip to a More...
From the standard view-based application, I found that the generated code did this: self.window.rootViewController
I am writing application which intented to replace standard/stock messenger. So I need to
I need to replace the a character in a text file with '?'. It's
I need replace slide effect to fade-out/fade-in effect on the prev and next slide

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.