tags:

views:

17

answers:

1

Hi I am new to iphone development.

I want to obtain string from url path For example, the relative path: 90-000000-General_Motors
i want to extract: General Motors
if path is 90-000000-General_Motors/5.jpg
i want to extract: 5

How can i acheive using simple coding

+2  A: 
NSString *lastPart = [[yourString pathComponents] lastObject];

Edit: Not sure if this is what you really want... What is so special about "General Motors" and "5"? Why no ending in the second case? This solution would give "5.jpg". Edit2: Used pathComponents: instead of componentsSeparatedByString:

Eiko
hi,thank you, it helped me a lot,but i have to extract name from url, if it is 90-000000-General_Motors i donot want numbers to be displayed,just General Motors ,if url is 90-000000-General_Motors/5.jpg ,the name to be displayed as 5 , here i should not remove numbers