From 214acf7e0f57e512484da1e7e24b2733d5063b74 Mon Sep 17 00:00:00 2001 From: Aadhavan Srinivasan Date: Mon, 10 Feb 2025 12:30:17 -0500 Subject: [PATCH] Wrote example for ReplaceAll(); fixed out-of-bounds bug in Expand() --- regex/example_test.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/regex/example_test.go b/regex/example_test.go index 913518c..4f868c6 100644 --- a/regex/example_test.go +++ b/regex/example_test.go @@ -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 +}