diff options
author | Valentin Vidic <vvidic@valentin-vidic.from.hr> | 2019-02-27 20:20:58 +0000 |
---|---|---|
committer | Ian Lance Taylor <iant@golang.org> | 2019-02-27 21:48:41 +0000 |
commit | 56f0c046cfe9019e30ad0d0f85ac974de394ebd7 (patch) | |
tree | 2bdbf75f65ef1c2a30511e3112f51947f8e22962 /src/regexp | |
parent | 9f9c5fa8c7b8ad4d6a691aa3f1b557a9216d838f (diff) | |
download | go-git-56f0c046cfe9019e30ad0d0f85ac974de394ebd7.tar.gz |
regexp: add ReplaceAllStringFunc example
Change-Id: I016312f3ecf3dfcbf0eaf24e31b6842d80abb029
GitHub-Last-Rev: 360047c9006dba643429c006f89d813d927999b3
GitHub-Pull-Request: golang/go#30445
Reviewed-on: https://go-review.googlesource.com/c/164257
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Diffstat (limited to 'src/regexp')
-rw-r--r-- | src/regexp/example_test.go | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/regexp/example_test.go b/src/regexp/example_test.go index 3008c56b6b..a44c9396de 100644 --- a/src/regexp/example_test.go +++ b/src/regexp/example_test.go @@ -7,6 +7,7 @@ package regexp_test import ( "fmt" "regexp" + "strings" ) func Example() { @@ -204,6 +205,13 @@ func ExampleRegexp_ReplaceAllString() { // -W-xxW- } +func ExampleRegexp_ReplaceAllStringFunc() { + re := regexp.MustCompile(`[^aeiou]`) + fmt.Println(re.ReplaceAllStringFunc("seafood fool", strings.ToUpper)) + // Output: + // SeaFooD FooL +} + func ExampleRegexp_SubexpNames() { re := regexp.MustCompile(`(?P<first>[a-zA-Z]+) (?P<last>[a-zA-Z]+)`) fmt.Println(re.MatchString("Alan Turing")) |