- Sort Score
- Result 10 results
- Languages All
Results 1 - 4 of 4 for TrimFunc (0.08 sec)
-
src/bytes/example_test.go
// Output: ["Achtung! Achtung"] } func ExampleTrimFunc() { fmt.Println(string(bytes.TrimFunc([]byte("go-gopher!"), unicode.IsLetter))) fmt.Println(string(bytes.TrimFunc([]byte("\"go-gopher!\""), unicode.IsLetter))) fmt.Println(string(bytes.TrimFunc([]byte("go-gopher!"), unicode.IsPunct))) fmt.Println(string(bytes.TrimFunc([]byte("1234go-gopher!567"), unicode.IsNumber))) // Output: // -gopher! // "go-gopher!"
Registered: Tue Nov 05 11:13:11 UTC 2024 - Last Modified: Wed Aug 07 17:22:36 UTC 2024 - 14.9K bytes - Viewed (0) -
src/bytes/bytes.go
if i >= 0 && s[i] >= utf8.RuneSelf { _, wid := utf8.DecodeRune(s[i:]) i += wid } else { i++ } return s[0:i] } // TrimFunc returns a subslice of s by slicing off all leading and trailing // UTF-8-encoded code points c that satisfy f(c). func TrimFunc(s []byte, f func(r rune) bool) []byte { return TrimRightFunc(TrimLeftFunc(s, f), f) } // TrimPrefix returns s without the provided leading prefix string.
Registered: Tue Nov 05 11:13:11 UTC 2024 - Last Modified: Tue Sep 03 20:55:15 UTC 2024 - 35.6K bytes - Viewed (0) -
src/bytes/bytes_test.go
func TestTrimFunc(t *testing.T) { for _, tc := range trimFuncTests { trimmers := []struct { name string trim func(s []byte, f func(r rune) bool) []byte out []byte }{ {"TrimFunc", TrimFunc, tc.trimOut}, {"TrimLeftFunc", TrimLeftFunc, tc.leftOut}, {"TrimRightFunc", TrimRightFunc, tc.rightOut}, } for _, trimmer := range trimmers { actual := trimmer.trim([]byte(tc.in), tc.f.f)
Registered: Tue Nov 05 11:13:11 UTC 2024 - Last Modified: Mon Aug 19 19:09:04 UTC 2024 - 61.2K bytes - Viewed (0) -
docs/debugging/xl-meta/main.go
b0 = fmt.Sprintf("%s: ", string(b)) } b, err := decode(r, file) if err != nil { return err } b = bytes.TrimSpace(b) if !ndjson { b = bytes.TrimFunc(b, func(r rune) bool { return r == '{' || r == '}' || r == '\n' || r == '\r' }) } toPrint = append(toPrint, fmt.Sprintf("%s%s", b0, string(b))) } } sort.Strings(toPrint)
Registered: Sun Nov 03 19:28:11 UTC 2024 - Last Modified: Thu Sep 05 11:57:44 UTC 2024 - 40.3K bytes - Viewed (0)