1
0
mirror of https://github.com/duke-git/lancet.git synced 2026-02-06 21:52:28 +08:00

feat: add Trim and SplitAndTrim

This commit is contained in:
dudaodong
2023-05-10 10:53:17 +08:00
parent c3f1bc39d7
commit 9fcf046fb3
3 changed files with 97 additions and 0 deletions

View File

@@ -539,3 +539,35 @@ func ExampleReplaceWithMap() {
// Output:
// 1c 12 12 1c
}
func ExampleTrim() {
result1 := Trim("\nabcd")
str := "$ ab cd $ "
result2 := Trim(str)
result3 := Trim(str, "$")
fmt.Println(result1)
fmt.Println(result2)
fmt.Println(result3)
// Output:
// abcd
// $ ab cd $
// ab cd
}
func ExampleSplitAndTrim() {
str := " a,b, c,d,$1 "
result1 := SplitAndTrim(str, ",")
result2 := SplitAndTrim(str, ",", "$")
fmt.Println(result1)
fmt.Println(result2)
// Output:
// [a b c d $1]
// [a b c d 1]
}