string.go 286 字节
Newer Older
E
eoLinker API Management 已提交
1 2 3 4
package utils

import "strings"

Y
Your Name 已提交
5
func TrimPrefixAll(s string, r string) string {
E
eoLinker API Management 已提交
6

Y
Your Name 已提交
7 8
	for strings.HasPrefix(s, r) {
		s = strings.TrimPrefix(s, r)
E
eoLinker API Management 已提交
9 10 11
	}
	return s
}
Y
Your Name 已提交
12
func TrimSuffixAll(s string, r string) string {
E
eoLinker API Management 已提交
13

Y
Your Name 已提交
14 15
	for strings.HasSuffix(s, r) {
		s = strings.TrimSuffix(s, r)
E
eoLinker API Management 已提交
16 17 18
	}
	return s

Y
Your Name 已提交
19
}