美文网首页
获取URL中的文件名

获取URL中的文件名

作者: 飞天蛤蟆 | 来源:发表于2016-11-18 14:10 被阅读0次

/这里有一个模拟器沙盒路径(完整路径)

NSString* index=@"/Users/junzoo/Library/Application Support/iPhone Simulator/7.0.3/Applications/63925F20-AF97-4610-AF1C-B6B4157D1D92/Documents/DownLoad/books/2013_50.zip";

对路径截取的9种操作

NSLog(@"1=%@",[index lastPathComponent]);

NSLog(@"2=%@",[index stringByDeletingLastPathComponent]);

NSLog(@"3=%@",[index pathExtension]);

NSLog(@"4=%@",[index stringByDeletingPathExtension]);

NSLog(@"5=%@",[index stringByAbbreviatingWithTildeInPath]);

NSLog(@"6=%@",[index stringByExpandingTildeInPath]);

NSLog(@"7=%@",[index stringByStandardizingPath]);

NSLog(@"8=%@",[index stringByResolvingSymlinksInPath]);

NSLog(@"9=%@",[[index lastPathComponent]stringByDeletingPathExtension]);

打印结果:

1=2013_50.zip

2=/Users/junzoo/Library/Application Support/iPhone Simulator/7.0.3/Applications/63925F20-AF97-4610-AF1C-B6B4157D1D92/Documents/DownLoad/books

3=zip

4=/Users/junzoo/Library/Application Support/iPhone Simulator/7.0.3/Applications/63925F20-AF97-4610-AF1C-B6B4157D1D92/Documents/DownLoad/books/2013_50

5=~/Documents/DownLoad/books/2013_50.zip

6=/Users/junzoo/Library/Application Support/iPhone Simulator/7.0.3/Applications/63925F20-AF97-4610-AF1C-B6B4157D1D92/Documents/DownLoad/books/2013_50.zip

7=/Users/junzoo/Library/Application Support/iPhone Simulator/7.0.3/Applications/63925F20-AF97-4610-AF1C-B6B4157D1D92/Documents/DownLoad/books/2013_50.zip

8=/Users/junzoo/Library/Application Support/iPhone Simulator/7.0.3/Applications/63925F20-AF97-4610-AF1C-B6B4157D1D92/Documents/DownLoad/books/2013_50.zip

9=2013_50

相关文章

  • JavaScript 获取url,html文件名,参数值

    1、获取url: 2、获取url中的文件名: 3、获取url中的指定参数的值:jquery从html路径中获取参数...

  • 获取URL中的文件名

    /这里有一个模拟器沙盒路径(完整路径) NSString* index=@"/Users/junzoo/Libra...

  • 从地址栏获取文件名

    从http地址中获取文件名称,已经记得使用 URLDecoder.decode(url) 解码

  • string处理函数

    取整 转换大小写 获取url中的文件名(主要用到parse_url、pathinfo两个函数) str_pad填充...

  • JQUERY获取当前页面的URL信息

    做网站需要经常使用jq获取当前url 所以收集了JQUERY获取URL的函数的资料 设置或获取对象指定的文件名或路...

  • js获取url路径信息

    1,设置或获取对象指定的文件名或路径。 2,设置或获取整个 URL 为字符串。 3,设置或获取与 URL 关联的端...

  • js获取地址栏信息

    设置或获取对象指定的文件名或路径。 设置或获取整个 URL 为字符串。 设置或获取与 URL 关联的端口号码。 设...

  • Js获取Url参数

    获取整个URL:window.location.href获取域名后面的文件名或路径:window.location...

  • js url 及字符串处理

    获取url 相关信息 设置或获取对象指定的文件名或路径。alert(window.location.pathnam...

  • PHP 一些函数

    获取url链接的相关信息 获取某路径下的文件名称 七天前的日期

网友评论

      本文标题:获取URL中的文件名

      本文链接:https://www.haomeiwen.com/subject/ayydpttx.html