package main import ( "fmt" "regexp" ) func main() { pattern := regexp.MustCompile(`go`) fmt.Println(pattern.MatchString("Golang")) fmt.Println(pattern.MatchString("go")) fmt.Println(pattern.MatchString("GOlang")) }
package main import ( "fmt" "regexp" ) func main() { pattern := regexp.MustCompile(`([a-z]+)\.([a-z]+)`) url := "https://www.example.com/index.html" result := pattern.FindStringSubmatch(url) fmt.Println(result[1]) fmt.Println(result[2]) }In this example, we use the FindStringSubmatch function to extract the domain and TLD from a given URL. The go regexp package is a part of the standard Go library.