Posted on 2007-09-25 16:57
angel 閱讀(217)
評論(0) 編輯 收藏
1、去左右空格
---左trim----
String s = " abc ";
s = s.replaceAll("^ +", "");
----右trim----
String s = " abc ";
s = s.replaceAll(" +$", "");
2、刪除子串 ,例如 :this is a cup 如何從第2個字符開始 刪除 4個字符
StringBuffer buff=new StringBuffer("this is a cup ");
buff.delete(2,4);
3、比較二個日期的大小
var dateStr= '2007-9-26';//格式是寫死的就是yyyy-MM-dd
var dateArr = dateStr.split('-');
var date = new Date(dateArr[0],dateArr[1],dateArr[2]);
var date1 = new Date();
alert(date>=date1?'大':'小');