This commit is contained in:
Anuraag (Rag) Agrawal 2024-09-18 00:01:39 -04:00 committed by GitHub
commit 101802726e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -226,6 +226,7 @@ func ExampleRegexp_ReplaceAll() {
re := regexp.MustCompile(`a(x*)b`)
fmt.Printf("%s\n", re.ReplaceAll([]byte("-ab-axxb-"), []byte("T")))
fmt.Printf("%s\n", re.ReplaceAll([]byte("-ab-axxb-"), []byte("$1")))
// Tries to find the named group `$1W` which is not present, so empty.
fmt.Printf("%s\n", re.ReplaceAll([]byte("-ab-axxb-"), []byte("$1W")))
fmt.Printf("%s\n", re.ReplaceAll([]byte("-ab-axxb-"), []byte("${1}W")))
@ -257,6 +258,7 @@ func ExampleRegexp_ReplaceAllString() {
re := regexp.MustCompile(`a(x*)b`)
fmt.Println(re.ReplaceAllString("-ab-axxb-", "T"))
fmt.Println(re.ReplaceAllString("-ab-axxb-", "$1"))
// Tries to find the named group `$1W` which is not present, so empty.
fmt.Println(re.ReplaceAllString("-ab-axxb-", "$1W"))
fmt.Println(re.ReplaceAllString("-ab-axxb-", "${1}W"))