Wrote function and example for ReplaceAllLiteral()

This commit is contained in:
2025-02-10 21:25:49 -05:00
parent 668df8b70a
commit 3b7257c921
2 changed files with 29 additions and 1 deletions

View File

@@ -162,3 +162,11 @@ func ExampleReg_ReplaceAll() {
fmt.Println(regexComp.ReplaceAll(inputStr, `$2$1`))
// Output: d5t9
}
func ExampleReg_ReplaceAllLiteral() {
regexStr := `fox|dog`
inputStr := "the quick brown fox jumped over the lazy dog"
regexComp := regex.MustCompile(regexStr)
fmt.Println(regexComp.ReplaceAll(inputStr, `duck`))
// Output: the quick brown duck jumped over the lazy duck
}