4845 explained code solutions for 96 technologies

golangHow to do regex replace

package main
import "regexp"

func main() {
  r := regexp.MustCompile(`[0-9]`)
  res := r.ReplaceAllString("+312-332-1432", "*")
}ctrl + c
package main

default package declaration

func main() {

declare main function that will be launched automatically


create regexp object and compile given pattern


replaces all substrings found by a regex pattern