Documentation ¶
Overview ¶
Package strs has miscellaneous functions for slices of strings
Package str has miscellaneous string functions Uses ascii package for lower/upper case
Index ¶
- func AfterFirst(s, sub string) string
- func AfterLast(s, sub string) string
- func BeforeFirst(s, sub string) string
- func BeforeLast(s, sub string) string
- func Capitalize(s string) string
- func Capitalized(s string) bool
- func CmpLower(s1, s2 string) int
- func Cut(s string, sep byte) (before, after string)
- func Doesc(s string, i int) (byte, int)
- func EqualCI(x, y string) bool
- func Find1of(s, chars string) int
- func FindLast1of(s, chars string) int
- func IndexFunc(s string, f func(byte) bool) int
- func Join(fmt string, list []string) string
- func Opt(strs ...string) string
- func Random(min, max int) string
- func RandomOf(min, max int, chars string) string
- func Split(s, sep string) []string
- func Subi(s string, i, j int) string
- func Subn(s string, i, n int) string
- func ToLower(s string) string
- func ToUpper(s string) string
- func UnCapitalize(s string) string
- func UniqueRandom(min, max int, seed ...int64) func() string
- func UniqueRandomOf(min, max int, chars string, seed ...int64) func() string
- type CommaBuilder
- type Queue
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AfterFirst ¶
AfterFirst returns s up to the first occurrence of sub or all of s if sub is not found.
func AfterLast ¶
AfterLast returns s after the last occurrence of sub or all of s if sub is not found.
func BeforeFirst ¶
BeforeFirst returns s up to the first occurrence of sub or all of s if sub is not found.
func BeforeLast ¶
BeforeLast returns s before the last occurrence of sub or all of s if sub is not found.
func Capitalize ¶
Capitalize returns the string with the first letter converted from a-z to A-Z
func Capitalized ¶
Capitalized returns true is the string starts with A-Z, otherwise false
func CmpLower ¶
CmpLower compares the ascii.ToLower of each character returning -1, 0, or +1 similar to strings.Compare
func Cut ¶
Cut slices s around the first instance of sep, returning the text before and after sep. If sep does not appear in s, cut returns s, "". Similar to the Go 1.18 strings.Cut (except it uses a string separator)
func FindLast1of ¶
func IndexFunc ¶
IndexFunc returns the index of the first byte that the func returns true for else -1
func Join ¶
Join joins strings with the specified format. The format may include delimiters e.g. "(,)"
func Opt ¶
Opt returns "" if any of the strings are "" else it returns the concatenation of the strings. e.g. Opt("=", s) or Opt(s, ",") or Opt("<", s, ">")
func Subi ¶
Subi returns the substring specified by a starting index and a limit index allowing indexes to exceed the string
func Subn ¶
Subn returns the substring specified by a starting index and a length allows index and length to exceed the string
func UnCapitalize ¶
UnCapitalize returns the string with the first letter converted from A-Z to a-z
func UniqueRandom ¶
Types ¶
type CommaBuilder ¶
type CommaBuilder struct {
// contains filtered or unexported fields
}
CommaBuilder builds a comma separated list. Zero value is ready to use.
func (*CommaBuilder) String ¶
func (cb *CommaBuilder) String() string
String returns the comma separated list