package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`(?s)<p>((?:(?!</?blockquote).)*?)</p>(?=(?:(?!</?blockquote).)*</blockquote>)`)
var str = `<blockquote>
<p>paragraph 1</p>
</blockquote>
<p>paragraph 1 outside blockquote</p>
<blockquote>
<p>paragraph 2</p>
<p>paragraph 3</p>
</blockquote>
<p>paragraph 2 outside blockquote</p>`
var substitution = "<div>\1</div>"
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/