在两个已知字符串之间搜索字符串

Flo*_*ked 2 objective-c nsstring

我有一个包含以下内容的字符串:

href="http://www.website.com/" /> [...] [...]
Run Code Online (Sandbox Code Playgroud)

我只是想得到字符串的中心部分.怎么可能得到@"href =""和@""/>之间的部分"

注意:即使它看起来像xml-code,它也在NSString中.

Flo*_*ked 10

我知道了!

这是代码(写得不是很好):

NSRange rr2 = [content rangeOfString:@"href=\""];
    NSRange rr3 = [content rangeOfString:@"\" />"];
    int lengt = rr3.location - rr2.location - rr2.length;
    int location = rr2.location + rr2.length;
    NSRange aa;
    aa.location = location;
    aa.length = lengt;
    theString = [theString substringWithRange:aa];
Run Code Online (Sandbox Code Playgroud)