中間体4桁の電話番号を交換してください*

//真ん中の4つの携帯電話番号を交換してください

VaRのSTR = '15、912341234' ;
//メソッド
str.replace(/(\ D {3 })(\ D {4})(\ D {3})/関数($ 0、$ 1、$ 2、$ 3){
console.log($ + 1 "****" + $ 3)
})
//方法II
str.replace(str.substr(3,4)、 '*' REPEAT)。(4);
//方法3つの
STR。 SUBSTR(0,3)+ "*" 。リピート(4)+ str.substr(7)

おすすめ

転載: www.cnblogs.com/beizhi666/p/10939568.html