• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSrange utilities
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.
References: 
 >NSrange utilities (From: Darin Duphorne <email@hidden>)

  • Prev by Date: Re: string coloring
  • Next by Date: Re: Apple and Developers (was lots of different subjects)
  • Previous by thread: NSrange utilities
  • Next by thread: Programmatically selecting items in a popup menu?
  • Index(es):
    • Date
    • Thread