您的位置:首页 > 其它

38-文件后缀名

2015-11-13 10:35 381 查看
<pre name="code" class="java">
//获取文件名,不带后缀

var file_name=file_path.replace(/(.*\/)*([^.]+).*/ig,"$2");

//获取文件后缀
1.var FileExt=file_path.replace(/.+\./,"");

2.var fileExtension = file_path.substring(file_path.lastIndexOf('.') + 1);

//截取文件后缀
var reg = /\.\w+$/;
var file_name = file_path.replace(reg,'');
<div> var postfix=file.substr(file.lastIndexOf(".")+1,file.length); </div>


java

public class StringDemo {
public static void main(String[] args) {

String str = "www.yiibai.com";
System.out.println(str);

// the end string to be checked
String endstr1 = ".com";
String endstr2 = ".org";

// checks that string str ends with given substring
boolean retval1 = str.endsWith(endstr1);
boolean retval2 = str.endsWith(endstr2);

// prints true if the string ends with given substring
System.out.println("ends with " + endstr1 + " ? " + retval1);
System.out.println("ends with " + endstr2 + " ? " + retval2);
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: