package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`(?m)\/(?: +[^\/\s]+)*\/ [^\/\s]+(?: +[^\/\s]+)*\/$`)
var str = `/Volumes/SAMPLES/ VOCALS/
/Volumes/SAMPLES/ VOCALS/ AFRICA/
=> /Volumes/SAMPLES/ VOCALS/ AcmeInc Club Vocals/
/Volumes/SAMPLES/ VOCALS/ AtomicInc Dance Vocals/
/Volumes/SAMPLES/ VOCALS/ AFRICA/ AfroInc Zulu Vocals/
/Volumes/SAMPLES/ VOCALS/ AFRICA/ SampleInc Warriors/
/Volumes/SAMPLES/ VOCALS/ AFRICA/ SampleInc Warriors/SampleInc_Warriors_Ululation/
/Volumes/SAMPLES/ VOCALS/ AFRICA/ SampleInc Warriors/SampleInc_Warriors_Drums/
/Volumes/SAMPLES/ VOCALS/ AFRICA/ AfroInc Zulu Vocals/ Folder1/`
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/