package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`(?m)^(?<variable>\w+)(?:\.(?<subvariable>\w+(?:\.\w+)*))??(?:\.(?<method>\w+)\((?<parameter>[^{}%\n]*)\))?$`)
var str = `core.settings
=> $core['settings']
core.set(param1, param2)
=> $core->set('param1', 'param2')
core.settings
core.get(param)
core.settings.time
core.settings.time.set(param)`
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/