直接上代码,这是比较挫的实现方法,不知各位大神有没有其它方法分享下
```
package main
import (
"fmt"
"strings"
)
func main() {
var phone string
phone = "13412345678"
old := ""
for k, v := range phone{
if k >=3 && k <=6{
old = old + string(v)
}
}
phone = strings.Replace(phone,old,"****",-1)
fmt.Println(phone) //134****5678
}
```
有疑问加站长微信联系(非本文作者)