Re: Getting a substring
Re: Getting a substring
- Subject: Re: Getting a substring
- From: Jerry Krinock <email@hidden>
- Date: Fri, 5 Dec 2008 17:35:03 -0800
On 2008 Dec, 05, at 14:03, Ariel Rodriguez wrote:
My question is simple, at least that is what i think :)
I need to extract something like this: 01816560 from something like
this: http://www.xxxx.com/diario/2008/12/05/um/m-01816560.htm My
first idea was to use - (NSArray *)componentsSeparatedByString:
(NSString *)separator with - first (to get the 01816560.htm and then
- (NSArray *)componentsSeparatedByString:(NSString *)separator again
with '.' But i am quite sure it should be a better way to do just
that.
Well, partially. If you make that string into an NSURL, you'll be
able to extract the -path, and then use the NSString methods -
lastPathComponent and -stringByDeletingPathExtension. The result will
be "m-01816560", and then you'll have to use some "manual" method, as
you have, from there.
Whether or not this is any "better" than they way you're doing it
depends on how that path might change in the future.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden