Skip to content

Commit

Permalink
fix trim
Browse files Browse the repository at this point in the history
  • Loading branch information
syyongx committed Aug 1, 2019
1 parent d00fdf2 commit e85a672
Showing 1 changed file with 6 additions and 15 deletions.
21 changes: 6 additions & 15 deletions php.go
Original file line number Diff line number Diff line change
Expand Up @@ -613,35 +613,26 @@ func StrShuffle(str string) string {

// Trim trim()
func Trim(str string, characterMask ...string) string {
mask := ""
if len(characterMask) == 0 {
mask = " \t\r\n\f\v"
} else {
mask = characterMask[0]
return strings.TrimSpace(str)
}
return strings.Trim(str, mask)
return strings.Trim(str, characterMask[0])
}

// Ltrim ltrim()
func Ltrim(str string, characterMask ...string) string {
mask := ""
if len(characterMask) == 0 {
mask = " \t\r\n\f\v"
} else {
mask = characterMask[0]
return strings.TrimLeftFunc(str, unicode.IsSpace)
}
return strings.TrimLeft(str, mask)
return strings.TrimLeft(str, characterMask[0])
}

// Rtrim rtrim()
func Rtrim(str string, characterMask ...string) string {
mask := ""
if len(characterMask) == 0 {
mask = " \t\r\n\f\v"
} else {
mask = characterMask[0]
return strings.TrimRightFunc(str, unicode.IsSpace)
}
return strings.TrimRight(str, mask)
return strings.TrimRight(str, characterMask[0])
}

// Explode explode()
Expand Down

0 comments on commit e85a672

Please sign in to comment.