diff --git a/regex/example_test.go b/regex/example_test.go index 9a881c5..f2443a2 100644 --- a/regex/example_test.go +++ b/regex/example_test.go @@ -30,3 +30,25 @@ func ExampleReg_FindAll() { // 3 4 // 5 6 } + +func ExampleReg_FindString() { + regexStr := `\d+` + regexComp := regex.MustCompile(regexStr) + + matchStr := regexComp.FindString("The year of our lord, 2025") + fmt.Println(matchStr) + // Output: 2025 +} + +func ExampleReg_FindSubmatch() { + regexStr := `(\d)\.(\d)(\d)` + regexComp := regex.MustCompile(regexStr) + + match, _ := regexComp.FindSubmatch("3.14") + fmt.Println(match[0]) + fmt.Println(match[1]) + fmt.Println(match[2]) + // Output: 0 4 + // 0 1 + // 2 3 +}