25 lines
740 B
Go
25 lines
740 B
Go
package stringfuncs
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
)
|
|
|
|
var f = fmt.Println
|
|
|
|
func StringFuncs() {
|
|
f("Trim", strings.Trim("***ohaiiooo*****", "*"))
|
|
f("Split", strings.Split("a-b-c-d-e", "-"))
|
|
f("SplitAfter", strings.SplitAfter("a-b-c-d-e", "-"))
|
|
f("ToUpper", strings.ToUpper("abc"))
|
|
f("ToLower", strings.ToLower("ABC"))
|
|
f("Replace (all)", strings.Replace("foo", "o", "0", -1))
|
|
f("Replace (few)", strings.Replace("foo", "o", "0", 1))
|
|
f("Contains", strings.Contains("foobar", "bar"))
|
|
f("Count", strings.Count("fuwafuwa", "w"))
|
|
f("HasPrefix", strings.HasPrefix("foobar", "foo"))
|
|
f("HasSuffix", strings.HasSuffix("foobar", "bar"))
|
|
f("Join", strings.Join([]string{"hello", "_", "world"}, ""))
|
|
f("Index", strings.Index("foobar", "bar"))
|
|
}
|