身份证保留前6 后四 ,
let number ="211212121212111212"
let length = number.length;
let qNumber = number.substring(0, 6);
let hNumber = number.substring(length - 4);
idCard = qNumber + '********' + hNumber;
银行卡每四位空格隔开
number.replace(/\s/g, '').replace(/....(?!$)/g, '$& ')
姓名2字显示姓,多个显示前后,中间*号代替
let nameLength = “输入的姓名”.length;
if (nameLength === 2) {
this.state.idName = this.state.cardInfo[0].name.substring(0, 1) + '*'
} else if (this.state.cardInfo[0].name.length > 2) {
let char = '';
for (let i = 0, len = this.state.cardInfo[0].name.length - 2; i < len; i++) {
char += '*';
}
this.state.idName = this.state.cardInfo[0].name.substr(0, 1) + char + this.state.cardInfo[0].name.substr(-1, 1);
} else {
this.state.idName = this.state.cardInfo[0].name;
}