package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`(?m)getopt(?:s|)(?: (?:-[a-zA-Z])*)*(?'name'[$a-zA-Z]+|)\s(?:(?:-o|--options) (?'short'.+) (?:-l|--longoptions|--long) (?'long'(?:[a-zA-Z0-9]|,|:|\$)+) \-\- \"\$@\"|(?:(?:(?:-[a-zA-Z])*|)\s*\"(?'while'(?:[a-zA-Z0-9]|,|:|\$)+)\"))`)
var str = `while getopts -a ":n:t:" options; do
while getopts -a -n ":n:t:" options; do
while getopt ":n:t:" options; do
Parameters=$(getopt -a -n $ScriptName --options $SHORT --longoptions $LONG -- "$@")
Parameters=$(getopt -a -n alphabet -o abc:d: --long alpha,bravo,charlie:,delta: -- "$@")`
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/