blob: c087be01bc9bc3b6572ff9d7d17aeaf58e6c28a6 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
package mailkit
// Strip_angle_brackets strips a single "<" from the
// front of the string and a single ">" from the back
// of the string. If either are present, stripped
// returns true; if both are present, balanced also
// returns true.
func Strip_angle_brackets(x string) (result string, stripped bool, balanced bool) {
var tmp string
if x[0] == '<' {
tmp = x[1:]
stripped = true
} else {
tmp = x
}
if tmp[len(tmp)-1] == '>' {
result = tmp[:len(tmp)-1]
if stripped {
balanced = true
} else {
stripped = true
}
} else {
result = tmp
}
return
}
|