身份證保留前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字顯示姓,多個(gè)顯示前后番枚,中間*號(hào)代替
? ? ? ? ? ?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;
??????????}