gitlab.com/evatix-go/core@v1.3.55/coreutils/stringutil/SplitFirstLast.go (about)

     1  package stringutil
     2  
     3  import (
     4  	"strings"
     5  
     6  	"gitlab.com/evatix-go/core/constants"
     7  	"gitlab.com/evatix-go/core/coreindexes"
     8  )
     9  
    10  func SplitFirstLast(s, separator string) (first, last string) {
    11  	splits := strings.Split(
    12  		s, separator,
    13  	)
    14  
    15  	length := len(splits)
    16  	first = splits[coreindexes.First]
    17  
    18  	if length > 1 {
    19  		return first, splits[length-1]
    20  	}
    21  
    22  	return first, constants.EmptyString
    23  }