blob: 5632006a40f77f801967509e119b2a224d4be81c [file] [log] [blame]
// Copyright 2025 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package morestrings
import "strings"
// CutLast is the "last" analogue of [strings.Cut].
func CutLast(s, sep string) (before, after string, ok bool) {
if i := strings.LastIndex(s, sep); i >= 0 {
return s[:i], s[i+len(sep):], true
}
return s, "", false
}