package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`.*http:\/\/.*\/([^;\?]+)`)
var str = `http://www.somesite.com/some/path/test.action;jsessionid=000063vCmvJAn7VWyymA_dPsHZs:16u9pglit?sort=2¶m1=1¶m2=2
http://www.somesite.com/some/path/test;jsessionid=000063vCmvJAn7VWyymA_dPsHZs:16u9pglit?sort=2¶m1=1¶m2=2
http://www.somesite.com/some/path/test.action?sort=2¶m1=1¶m2=2
http://www.somesite.com/some/path/test?sort=2¶m1=1¶m2=2`
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/