1
0
mirror of https://github.com/duke-git/lancet.git synced 2026-02-07 14:12:28 +08:00

feat: add Substring function

This commit is contained in:
dudaodong
2022-12-29 19:55:40 +08:00
parent b5f7b0e670
commit 1dc5e8ac23
3 changed files with 59 additions and 0 deletions

View File

@@ -337,3 +337,27 @@ func ExampleUnwrap() {
// foo*
// *foo*
}
func ExampleSubstring() {
result1 := Substring("abcde", 1, 3)
result2 := Substring("abcde", 1, 5)
result3 := Substring("abcde", -1, 3)
result4 := Substring("abcde", -2, 2)
result5 := Substring("abcde", -2, 3)
result6 := Substring("你好,欢迎你", 0, 2)
fmt.Println(result1)
fmt.Println(result2)
fmt.Println(result3)
fmt.Println(result4)
fmt.Println(result5)
fmt.Println(result6)
// Output:
// bcd
// bcde
// e
// de
// de
// 你好
}