Skip to content

Instantly share code, notes, and snippets.

@vianhanif
Created November 20, 2019 21:05
Show Gist options
  • Save vianhanif/7f2947867a02b380043ea28ffb592405 to your computer and use it in GitHub Desktop.
Save vianhanif/7f2947867a02b380043ea28ffb592405 to your computer and use it in GitHub Desktop.
sample-go.go
package main
import (
"fmt"
"regexp"
"strings"
)
func main() {
//mat3 := regexp.MustCompile(`[a-zA-Z0-9]`)
matched1 := regexp.MustCompile(`%%[a-zA-Z0-9]^\s')
matched2 := regexp.MustCompile(`[a-zA-Z0-9]%%`)
str := strings.ReplaceAll("%%buku%% and title %%code%%", "", "")
str = matched1.ReplaceAllString("%%buku%% and title %%code%%", `'%%`)
fmt.Println(str)
fmt.Println(matched2.ReplaceAllString(str, "%%'"))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment