Wrote example for Longest()

This commit is contained in:
2025-02-09 15:47:57 -05:00
parent af15904f3b
commit 9fbb99f86c

View File

@@ -78,3 +78,14 @@ func ExampleReg_LiteralPrefix() {
// Output: a
// false
}
func ExampleReg_Longest() {
regexStr := `x|xx`
inputStr := "xx"
regexComp := regex.MustCompile(regexStr)
fmt.Println(regexComp.FindString(inputStr))
regexComp.Longest()
fmt.Println(regexComp.FindString(inputStr))
// Output: x
// xx
}