0) { var valueLen = value.length; if (Array.isArray(group) && group.length > 0) { group = grou_c#split()分组后变为单个字符如何重新组为字">
赞
踩
function RegroupStr(group, value, splitstr, maxlen) { if (typeof value == "string" && value.length > 0) { var valueLen = value.length; if (Array.isArray(group) && group.length > 0) { group = group.sort(function (a, b) { return a - b; }).filter((x) => { if (typeof x == "number" && x > 0 && x % 1 === 0) { return x } }); var strsplit = "-"; var newValue = ""; if (splitstr != undefined&& typeof splitstr === "string") { strsplit = splitstr; } if (group.length > 0) { if (typeof splitstr == "number") { strsplit = "-"; valueLen = splitstr; } if (maxlen && typeof maxlen == "number") { valueLen = maxlen; } if (group.indexOf(valueLen) == -1 && group[group.length - 1] < valueLen) { group.push(valueLen); } group = Array.from(new Set(group)); $.each(group, function (i, _i) { if (i != 0) { i = group[i - 1]; } newValue += value.substring(i, _i) + strsplit; }) while (newValue.substring(newValue.length - 1, newValue.length) == strsplit) { newValue = newValue.substring(0, newValue.length - 1); } return newValue; } } } return ""; }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。