From a76fa6335572e8cbc110965a3e59b956c3c175da Mon Sep 17 00:00:00 2001 From: Zeskbest Date: Tue, 31 Dec 2024 15:27:35 +0700 Subject: [PATCH] added strings.HasPrefixSuffix --- src/strings/strings.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/strings/strings.go b/src/strings/strings.go index 7eb2de635c3b3c..e9726954925a9b 100644 --- a/src/strings/strings.go +++ b/src/strings/strings.go @@ -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.