<a idref="_5AD480AC_7D6C_4AA6_B003_F1C5F38F4D15"
   sectionid="n1e14b600d6dec639" internal="true" type="text"
   slug="histologie/quergestreifte+muskulatur+histologie" link="" ui-
   sref="main.learn.content({slug:
   'histologie/quergestreifte+muskulatur+histologie', '#':
   '_5AD480AC_7D6C_4AA6_B003_F1C5F38F4D15'})" webtrends-track-on-click="
   {'WT.i_module': 'Textlink - Intern'}" >
   ultrastrukturelle Aufbau der Myofilamente
</a>

我有以上内容作为回应。我只想将该字符串更改为下面。

怎么获得:
href="/lernmodule/histologie/quergestreifte+muskulatur+histologie#_5AD480AC_7D6C_4AA6_B003_F1C5F38F4D15"

从上面的字符串?

最佳答案

如果您的回答的格式是特定的,如您的问题中所示,那么下面的代码将为您服务:

    NSString *match = @"internal";
    NSString *postTel;
    NSString *preTel;

    NSScanner *scanner = [NSScanner scannerWithString:str];
    [scanner scanUpToString:match intoString:&preTel];

    [scanner scanString:match intoString:nil];
    postTel = [str substringToIndex:scanner.scanLocation];

    NSString*requiredString=[[postTel substringFromIndex:3] stringByReplacingOccurrencesOfString:@"internal" withString:@""];

10-04 20:03