How do i select a substring from a string acording to the last "/"?
I have a image url and would like to subtract the last string after "/" , for example from string "www.abc.com/images/photo.jpg" i would like t开发者_运维知识库o get the string "photo.jpg". How can i do this ?
Use NSString
-(NSString *)lastPathComponent;
for that.
String s = "www.abc.com/images/photo.jpg";
String[] newS = s.split("/");
String correctS = newS[newS.length-1];
correctS will hold your answer
Here's a regex for it:
(?!/)[^/]*$
精彩评论