package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`SALARY:(?P<salary_min>\d+(?:k|K)?)(?:\s*\-\s*(?P<salary_max>\d+(?:k|K)?)?)?(?:\s?(?P<currency>[A-Za-z]{3}))?`)
var str = `SALARY:120k-200kUSD
SALARY:120k EUR
SALARY:120000 PLN
SALARY:120k-200kusd
SALARY:120k-200k`
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/