package main
import (
"fmt"
"regexp"
"strings"
)
func main() {
str1 := "Go is a [statically] [[typed]], compiled [programming] language"
re := regexp.MustCompile(`\[([^\[\]]*)\]`)
submatchall := re.FindAllString(str1, -1)
for _, element := range submatchall {
element = strings.Trim(element, "[")
element = strings.Trim(element, "]")
fmt.Println(element)
}
}
/*
run:
statically
typed
programming
*/