package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`(?m)href="([^#]*?)(#[^"]*?)"`)
var str = `<a href="/#abc">test</a>
<a href="#def">test2</a>
<a href="/index.php?a=1#feg">test3</a>
<a href="/test.php?c=2">test4</a>
<a href="/test">test5</a>
`
var substitution = "href="$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/