Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

strings/HasPrefixSuffix: handle both prefix and suffix #71072

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/strings/strings.go
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,11 @@ func HasSuffix(s, suffix string) bool {
return stringslite.HasSuffix(s, suffix)
}

// HasPrefixSuffix eports whether the string s begins with prefix and ends with suffix.
func HasPrefixSuffix(s, prefix, suffix string) bool {
return stringslite.HasPrefix(s, prefix) && stringslite.HasSuffix(s, suffix)
}

// Map returns a copy of the string s with all its characters modified
// according to the mapping function. If mapping returns a negative value, the character is
// dropped from the string with no replacement.
Expand Down