package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`(?P<open_dsq>(?<!\\)["\'])(?P<dsq_value>(?s:\\.|(?!\\|(?P=open_dsq)).)*?)(?P<close_dsq>(?P=open_dsq))`)
var str = `$single_quoted = 'hello world';
$double_quote = "hi there";
$escaped_single_quote = 'it\'s tricky';
$escaped_double_quotes = "\"it's\" tricky";
`
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/