From 68bd574b90799d76564e74d7f0e8233c1b62beab Mon Sep 17 00:00:00 2001 From: Mark McGranaghan Date: Wed, 19 Sep 2012 23:20:15 -0700 Subject: [PATCH] some string stuff --- README | 1 - src/44-string-fns.go | 3 ++- src/xx-regexs.go | 4 +++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/README b/README index 0adc735..3d1d070 100644 --- a/README +++ b/README @@ -61,7 +61,6 @@ gobyexample.com signups * using gofmt * scrolls style logging * range and close http://tour.golang.org/#66 -* string replacement - sub & gsub * benchmarking * profiling diff --git a/src/44-string-fns.go b/src/44-string-fns.go index e77506e..e9fef2c 100644 --- a/src/44-string-fns.go +++ b/src/44-string-fns.go @@ -14,7 +14,8 @@ func main() { p(strings.Index("test", "e")) p(strings.Join([]string{"a","b"}, "-")) p(strings.Repeat("a", 5)) - p(strings.Replace("aaaa", "a", "b", 2)) + p(strings.Replace("foo", "o", "0", -1)) + p(strings.Replace("foo", "o", "0", 1)) p(strings.Split("a-b-c-d-e", "-")) p(strings.ToLower("TEST")) p(strings.ToUpper("test")) diff --git a/src/xx-regexs.go b/src/xx-regexs.go index 56c0679..62e4a7f 100644 --- a/src/xx-regexs.go +++ b/src/xx-regexs.go @@ -13,4 +13,6 @@ func main() { fmt.Println(r1.MatchString("peach")) } -// todo more +// == todo +// more +// gsub with regexp