package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`(\b(?:G,C,D|A,B,C|E,C,D)|(?:[ABCDEFG](?:#|b)?)(?:\/[ABCDEFG]b)?(?:(?:(?:maj|min|sus|add|aug|dim)(?:\d{0,2}(?:#\d{1,2}|sus\d)?)?)|(?:m\d{0,2}(?:(?:maj|add|#)\d{0,2})?)|(?:-?\d{0,2}(?:\([^)]*\)|#\d{1,2})?))?)`)
var str = `1er couplet:
Gm G
Mon enfant, nue sur les galets
G D7
Le vent dans tes cheveux defaits
Dsus Cmaj
Comme un printemps sur mon trajet
C Em
Un diamant tombé d'un coffret`
var substitution = "[${1}]"
fmt.Println(re.ReplaceAllString(str, substitution))
}
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for Golang, please visit: https://golang.org/pkg/regexp/