feat: add SubInBetween

This commit is contained in:
dudaodong committed 2024-02-06 16:47:30 +08:00
1 parent fa298b740d
commit f9e047f190
5 files changed
+108 -2

No files matched your search

+12
View File
@@ -574,3 +574,15 @@ func RemoveWhiteSpace(str string, repalceAll bool) string {
return strings.TrimSpace(str)
}
// SubInBetween return substring between the start and end position(excluded) of source string.
// Play: todo
func SubInBetween(str string, start string, end string) string {
if _, after, ok := strings.Cut(str, start); ok {
if before, _, ok := strings.Cut(after, end); ok {
return before
}
}
return ""
}