Re: NSrange utilities
Re: NSrange utilities
- Subject: Re: NSrange utilities
- From: Ondra Cada <email@hidden>
- Date: Sun, 24 Mar 2002 19:32:58 +0100
On Sunday, March 24, 2002, at 05:58 , Darin Duphorne wrote:
How can I obtain a range between and including two different characters?
(i.e., a NSRange representing "<tag>" from the string "This is <tag> a
sample string."
I guess you would want a more flexible solution, but eg.
NSRage rr=[s rangeOfString:@"<"];
NSRage ss=[s rangeOfString:@">" options:0 range:NSMakeRange(rr.location,[s
ength]-rr.location)];
return NSMakeRange(rr.location,ss.location-rr.location);
is a good starting point. Add checks for special cases (like if there is
no tag at all or a malformed one), and add whatever next you might want to
(like skipping "...." in tags)...
---
Ondra Cada
OCSoftware: email@hidden
http://www.ocs.cz
2K Development: email@hidden
http://www.2kdevelopment.cz
private email@hidden
http://www.ocs.cz/oc
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.