package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`(?s)<!DOCTYPE html>.+?<body>(?-s)`)
var str = `<!DOCTYPE html>
<meta charset="utf-8">
<meta name="generator" content="pandoc">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
<title></title>
<style>code{white-space: pre;}</style>
<![endif]-->;
<body>
afterwards`
if len(re.FindStringIndex(str)) > 0 {
fmt.Println(re.FindString(str),"found at index",re.FindStringIndex(str)[0])
}
}
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/