package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`(?i)\{([a-z_]\w*)\}`)
var str = `Original example:
{login}:{password}:{ip}
What about other field names? \`e-mail\` would be acceptable depending on the DB but it's
probably not a good idea to create field names with special chars.
{_ipv6},{name},{e-mail},{1_not_ok_with_leading_numbers}
`
for i, match := range re.FindAllString(str, -1) {
fmt.Println(match, "found at index", i)
}
}
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/