package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`(?m)^Match[\s\S]*?(?=^$|\Z)`)
var str = `Match User thedomain\user1
ChrootDirectory E:\sftp\heatism\user1
PermitTunnel no
AllowAgentForwarding no
AllowTcpForwarding no
X11Forwarding no
ForceCommand internal-sftp
Match User thedomain\user2
ChrootDirectory E:\sftp\heatism\user2
PermitTunnel no
AllowAgentForwarding no
AllowTcpForwarding no
X11Forwarding no
ForceCommand internal-sftp
Match User thedomain\user3
ChrootDirectory E:\sftp\heatism\user3
PermitTunnel no
AllowAgentForwarding no
AllowTcpForwarding no
X11Forwarding no
ForceCommand internal-sftp`
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/