Documentation ¶
Index ¶
- func CountBytes(s string, b byte) (count int)
- func CountRunes(s string, r rune) (count int)
- func Cut(text, sep string) (left, right string, ok bool)
- func Cut2(text, sub string) (s0, s1, s2 string, ok bool)
- func Cut2Byte(text string, sep byte) (s0, s1, s2 string, ok bool)
- func Cut2Rune(text string, sep rune) (s0, s1, s2 string, ok bool)
- func CutAfter(s, sub string) (left, right string, ok bool)
- func CutByte(s string, sep byte) (string, string, bool)
- func CutByteAfter(s string, delim byte) (string, string, bool)
- func CutRune(s string, r rune) (string, string, bool)
- func CutRuneAfter(s string, r rune) (string, string, bool)
- func RunesIn(s string) (runes int)
- func SortedBytes(s string) []byte
- func SortedRunes(s string) []rune
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CountRunes ¶
CountRunes returns the number of copies of r in s. Be warned that unicode-equivalent code points do not always compare equally.
CountRunes(`🔥aaab🔥c🔥`, '🔥') >> 2
func Cut ¶
// alias for strings.Cut
Cut slices s around the first instance of sep, returning the text before and after sep. The found result reports whether sep appears in s. If sep does not appear in s, cut returns s, "", false.
if left, right, _ := Cut("my name is", " ")); left != "my", right != "name is" { panic("bad cut!") }
func Cut2 ¶
Cut slices s around the first two appearances of sep. The found result reports whether sep appears at least twice in s. If sep does not appear in s, cut returns "", "", false.
s0, s1, s2, _ := fmt.Println(Cut2("a__b__c__d", "__") fmt.Printf("%s %s %s\n", s0, s1, s2) >> a b c__d
func CutAfter ¶
CutAfter splits s immediately after the first occurence of sub ok is false if sub is not present. If sep does not appear in s, CutAfter returns s, "", false.
func CutByteAfter ¶
CutByteOnce is as CutAfter, but delim is a byte, not a string.
func SortedBytes ¶
SortedBytes returns the bytes of the string, sorted as u8s.
func SortedRunes ¶
SortedRunes returns the runes of the string, sorted as i32s. be warned that unicode-equivalent strings do not necessarially sort identically, due to composed & decomposed forms, unicode equivalence, etc.
Types ¶
This section is empty.