1 str = 'A123456B' 2 3 data = str.match(/(.)?(.*)(.)$/) 4 // data = ['A123456B', 'A', '123456', 'B'] 5 // data = [完整字符串 , 首字符 , 中间字符串 , 尾字符] 6 7 Str = data[1] + data[2].replaceAll(/./g,'*')+data[3] 8 // Str = 'A******B'
字符串也能被替换掉
偷学到一个
标签:字符,正则,Str,字符串,data,替换,A123456B From: https://www.cnblogs.com/HE0318bei/p/16844990.html