package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`(?<=href=')()(?={{.*}})`)
var str = `<a href='{{url}}'>Link</a>
<p>This text {{urlAltTag}} will not get replaced</p>
<a href='{{urlAltTag}}' download='true'>Another Link</a>`
var substitution = "https://myurl.com?redirect=\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/