日期:2014-05-16 浏览次数:20496 次
var str1 = "aa;bb;cc;"; var str2 = "aa;bb;cc"; var str3 = ";aa;bb;cc"; var str4 = ";aa;bb;cc;"
var s = ["aa;bb;cc;","aa;bb;cc",";aa;bb;cc",";aa;bb;cc;"]; for(var i=s.length-1;i>=0;i--)s[i]=s[i].replace(/(^[^;])/,';$1').replace(/([^;]$)/,'$1;'); //检测 for(var i=0,il=s.length;i<il;i++)alert(s[i]);