At 20:03 -0200 5/12/08, 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. Any idea?

It entirely depends on how the URL can change.

If the URL is always the same format, then you could just use substringWithRange with an appropriate range.

If the URL can change somewhat, and it is just the last component, then you could use lastPathComponent to get the last piece, and stringByDeletingPathExtension to remove the extension.

After that, how you get rid of the m- depends on how that part changes.

Ultimately, you could use a regex library, but while I find that indispensable, its probably overkill for this task.

Enjoy,
   Peter.

--
              Keyboard Maestro 3 Now Available!
                Now With Status Menu triggers!

Keyboard Maestro <http://www.keyboardmaestro.com/> Macros for your Mac
<http://www.stairways.com/>           <http://download.stairways.com/>
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to