package main import ( "fmt" "regexp" ) func main() { regex := regexp.MustCompile(`\d+`) match := regex.FindString("The price is $123.45") fmt.Println(match) //output: 123 }
package main import ( "fmt" "regexp" ) func main() { regex := regexp.MustCompile(`[a-z]+`) match := regex.FindString("The quick brown fox") fmt.Println(match) //output: The }This example uses Regexp FindString to search for the first instance of one or more lowercase alphabetical characters ([a-z]+) in the input string "The quick brown fox". The function returns the matched string "The". The package library used in these examples is "regexp".