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

implementBackreferences
Aadhavan Srinivasan 4 weeks ago
parent 50221ff4d9
commit 214acf7e0f

@ -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
}

Loading…
Cancel
Save