日期:2014-05-16 浏览次数:20415 次
function addOne(str){
var str1 = str.substring(0,str.length-5) ;
var str2 = str.substring(str.length-5,str.length) ;
if(str2.substring(0,1) == 0){
str2 = "1"+str2 ;
str2 = Number(str2) + 1;
}else{
str2 = Number(str2) + 1;
}
str2 = (str2+"").substring(1,str2.length) ;
str = str1 + str2 ;
return str
}
<script type="text/javascript">
function dealfun(str){
return str.replace(/\d+$/,function(a){
var o="",i=l=a.length;
while(i){
o+="0";i--;
}
return (o+(parseInt(a)+1)).slice(l*-1);
})
}
var str = "AB0999999";
console.log(dealfun(str));
</script>
function and1(str)
{
return str.replace(/\d+$/,function(n){
var nc = parseInt(n, 10)+1+"";
var s0 = n.replace(/\d/g,"0").substr(0,n.length-nc.length);
return s0+nc;
});
}
alert(and1("abc0077"));
alert(and1("abc0999"));
alert(and1("abc9999"));
var str1 = 'A00000001';
var str2 = '000000008';
var str3 = '0000323239';
var str4 = '001232330';
var str5 = '101232335';
var str6 = '251232349';
var str7 = 'AB0000029';
var str8 = 'AB100992321';
var str9 = 'ABC0223204';
String.prototype.Yadd = function(step){
return this.replace(/[1-9]\d*/,function(n){
return parseInt(n)+1;
});
}
console.log(str1.Yadd(1));
console.log(st