Wrote example for ReplaceAll(); fixed out-of-bounds bug in Expand()
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
Reference in New Issue
Block a user