<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"
来自上面的字符串?
答案 0 :(得分: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:@""];
答案 1 :(得分:0)
strContent=[strContent stringByReplacingOccurrencesOfString:@"', '#': '" withString:@"'#"];
strContent=[strContent stringByReplacingOccurrencesOfString:@"'})\" web" withString:@"\" web"];
strContent=[strContent stringByReplacingOccurrencesOfString:@"({slug: '" withString:@" \" href=\"/lernmodule/"];
strContent=[strContent stringByReplacingOccurrencesOfString:@"\"\"#" withString:@"#"];