FROM : Mr. Gecko
DATE : Thu May 15 01:25:12 2008
Hello I am trying to find out how to get characters in the middle of
two characters I have heard of NSRange but I can't find documentation
to it in xcode.
So here is what I am trying to do in this html page on line there are
to points which stays the same and in the middle of the points is what
I need here is an example.
<a href="example.com" title="Ttitle">text I want</a>
so I want to get the text in the middle of points title="Ttitle"> and
</a>
Here is what I tried and did not work
NSString *url = [NSString stringWithContentsOfURL:[NSURL
URLWithString:@"http://www.example.com/file.html"]];
NSString *s = url;
NSRange f, l;
f = [url rangeOfString:@"{\" title=\"Ttitle\">"];
if (f.location == NSNotFound) NSLog(@"failed");
s = [s substringFromIndex:f.location + f.length];
l = [s rangeOfString:@",\"</a>\""];
if (l.location == NSNotFound) NSLog(@"failed");
s = [s substringFromIndex:f.location + l.location];
I wanted s to equal the text in the middle but it does not.
DATE : Thu May 15 01:25:12 2008
Hello I am trying to find out how to get characters in the middle of
two characters I have heard of NSRange but I can't find documentation
to it in xcode.
So here is what I am trying to do in this html page on line there are
to points which stays the same and in the middle of the points is what
I need here is an example.
<a href="example.com" title="Ttitle">text I want</a>
so I want to get the text in the middle of points title="Ttitle"> and
</a>
Here is what I tried and did not work
NSString *url = [NSString stringWithContentsOfURL:[NSURL
URLWithString:@"http://www.example.com/file.html"]];
NSString *s = url;
NSRange f, l;
f = [url rangeOfString:@"{\" title=\"Ttitle\">"];
if (f.location == NSNotFound) NSLog(@"failed");
s = [s substringFromIndex:f.location + f.length];
l = [s rangeOfString:@",\"</a>\""];
if (l.location == NSNotFound) NSLog(@"failed");
s = [s substringFromIndex:f.location + l.location];
I wanted s to equal the text in the middle but it does not.
| Related mails | Author | Date |
|---|---|---|
| Mr. Gecko | May 15, 01:25 | |
| Randall Meadows | May 15, 01:33 | |
| Mr. Gecko | May 15, 01:39 | |
| Andy Lee | May 15, 01:48 | |
| Jens Alfke | May 15, 06:22 |






Cocoa mail archive

