Wrote example for ReplaceAll(); fixed out-of-bounds bug in Expand()

This commit is contained in:
2025-02-10 12:30:17 -05:00
parent 50221ff4d9
commit 214acf7e0f

View File

@@ -154,3 +154,11 @@ func ExampleReg_Longest() {
// Output: x
// xx
}
func ExampleReg_ReplaceAll() {
regexStr := `(\d)(\w)`
inputStr := "5d9t"
regexComp := regex.MustCompile(regexStr)
fmt.Println(regexComp.ReplaceAll(inputStr, `$2$1`))
// Output: d5t9
}