开发者

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:

(?!/)[^/]*$

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜