自行过滤
/**
- 获取a-Z
- @param str
- @returns {string}
*/
function getVal(str, maxlen) {
var ar = str.split("");
var last = “”;
var i = ar.length - 1;
function f(i) {
if (i == -1) {
return;
}
//最小位
var min = ar[i];
var tmp = getBef(min);
if (tmp === “a”) {
f(i - 1);
}
last += tmp;
}
function getBef(str) {
var num = str.charCodeAt();
if (num === 90) {
num += 6;
}
if (num === 122) {
num = 64;
}
return String.fromCharCode(num + 1);
}
f(i);
last = last.split("");
for (var j = 0; j < last.length; j++) {
ar[ar.length - 1 - j] = last[last.length - 1 - j];
}
var tag = false;
ar.forEach(function (node) {
if (node !== “a”) {
tag = true;
}
})
var ret = ar.join("")
if (ret.length <= maxlen) {
if (tag) {
return ret;
} else {
return ret + “a”;
}
}else {
return 0;
}
}