Get last path part from NSString

前端 未结 7 1065
梦毁少年i
梦毁少年i 2020-12-13 19:20

Hi all i want extract the last part from string which is a four digit number \'03276\' i:e http://www.abc.com/news/read/welcome-new-gig/03276

how can i

7条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-13 19:36

    NSString *str = @"http://www.abc.com/news/read/welcome-new-gig/03276";  
    NSArray *arr = [str componentSeparatedBy:@"gig/"];  
    NSString *strSubStringDigNum = [arr objectAtIndex:1];  
    

    strSubStringDigNum will have the value 03276

提交回复
热议问题