2016-12-20 3 views
1
<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> 

У меня есть содержание в качестве ответа. Я просто хочу изменить эту строку ниже.Как изменить конкретную строку из абзаца в ios?

Как добраться:

href="/lernmodule/histologie/quergestreifte+muskulatur+histologie#_5AD480AC_7D6C_4AA6_B003_F1C5F38F4D15" 

из приведенных выше строк?

ответ

0
 strContent=[strContent stringByReplacingOccurrencesOfString:@"', '#': '" withString:@"'#"]; 
      strContent=[strContent stringByReplacingOccurrencesOfString:@"'})\" web" withString:@"\" web"]; 
      strContent=[strContent stringByReplacingOccurrencesOfString:@"({slug: '" withString:@" \" href=\"/lernmodule/"]; 
     strContent=[strContent stringByReplacingOccurrencesOfString:@"\"\"#" withString:@"#"]; 
1

Если формат вашего ответа специфично, как вы показали в вашем вопросе, то ниже код будет работать для вас:

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:@""]; 
Смежные вопросы