Skip to content

SplitEx方法的文档描述输入和输出的结果对不上:5个示例输出4个结果 #355

Description

@aofengcanyue

SplitEx
分割字符串为切片,removeEmptyString参数指定是否去除空字符串。

函数签名:

go
func SplitEx(s, sep string, removeEmptyString bool) []string
示例:运行

go
import (
"fmt"
"github.com/duke-git/lancet/v2/strutil"
)

func main() {
result1 := strutil.SplitEx(" a b c ", "", true)

result2 := strutil.SplitEx(" a b c ", " ", false)
result3 := strutil.SplitEx(" a b c ", " ", true)

result4 := strutil.SplitEx("a = b = c = ", " = ", false)
result5 := strutil.SplitEx("a = b = c = ", " = ", true)

fmt.Println(result1)
fmt.Println(result2)
fmt.Println(result3)
fmt.Println(result4)
fmt.Println(result5)

// Output:
// []
// [ a b c ]
// [a b c]
// [a b c ]

}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions