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 to 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:
(?!/)[^/]*$
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.