package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`\{((?:[^{}]*\{[^{}]*\})*[^}]*)\}`)
var str = `<html>
<head>
<title>DailyHoroscope.com</title>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">
{if $contact['timezone']}
{assign var=local_tz value=$contact['timezone']}
{else}
{assign var=local_tz value='America/New_York'}
{/if}
{assign var=tracking_params value="utm_medium={$medium}&utm_source={$source}&utm_campaign={$campaign}"}
</head>
<body style="background:#fff;">
</body>
</html>`
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/