Documentation ¶
Index ¶
- Variables
- func Glue(strs ...string) string
- func Len(s string) int
- func NewRemover(rm ...string) *strings.Replacer
- func ScannerFactory(str string) liter.Factory[rune]
- type And
- type Joiner
- type Matcher
- type MatcherFunc
- type Not
- type Or
- type Range
- type Rune
- type Scanner
- func (s *Scanner) Cur() (r rune, done bool)
- func (s *Scanner) Done() bool
- func (s *Scanner) Idx() int
- func (s *Scanner) Iter() liter.Wrapper[rune]
- func (s *Scanner) Many(m Matcher) bool
- func (s *Scanner) Match(m Matcher) bool
- func (s *Scanner) Next() (r rune, done bool)
- func (s *Scanner) Peek(m Matcher) bool
- func (s *Scanner) Reset()
- type Seperator
- func (s Seperator) BufJoin(elems []string, buf []byte) string
- func (s Seperator) Index(str string) int
- func (s Seperator) Join(elems ...string) string
- func (s Seperator) JoinLen(elems []string) int
- func (s Seperator) Joiner(elems ...string) *Joiner
- func (s Seperator) Split(str string) slice.Slice[string]
- type Strings
- func (s *Strings) Cur() (str string, done bool)
- func (s *Strings) Date(layout string) (t time.Time)
- func (s *Strings) Done() bool
- func (s *Strings) Float64() (f float64)
- func (s *Strings) Idx() int
- func (s *Strings) Int() (i int)
- func (s *Strings) Len() int
- func (s *Strings) Next() (str string, done bool)
- func (s *Strings) Regex(re *regexp.Regexp, skipEmpty bool) []string
- func (s *Strings) Start() (str string, done bool)
- func (s *Strings) Sub(split string) *Strings
- type SubStrings
Constants ¶
This section is empty.
Variables ¶
var DefaultPreprocess = func(str string) (skip bool, cleaned string) { cleaned = strings.TrimSpace(str) skip = cleaned == "" return }
var NumericReplacer = NewRemover(",", "$", "%")
Functions ¶
func NewRemover ¶
Types ¶
type And ¶
type And []Matcher
And takes many Matcher and returns true if all of them return true for a rune.
type MatcherFunc ¶
MatcherFunc wraps a func so it fulfills Matcher.
var ( IsLetter MatcherFunc = unicode.IsLetter IsNumber MatcherFunc = unicode.IsNumber IsDigit MatcherFunc = unicode.IsDigit IsControl MatcherFunc = unicode.IsControl IsGraphic MatcherFunc = unicode.IsGraphic IsLower MatcherFunc = unicode.IsLower IsMark MatcherFunc = unicode.IsMark IsPrint MatcherFunc = unicode.IsPrint IsPunct MatcherFunc = unicode.IsPunct IsSpace MatcherFunc = unicode.IsSpace IsTitle MatcherFunc = unicode.IsTitle IsUpper MatcherFunc = unicode.IsUpper )
func (MatcherFunc) Matches ¶
func (fn MatcherFunc) Matches(r rune) bool
Matches calls the underlying MatcherFunc.
type Or ¶
type Or []Matcher
Or takes many Matcher and returns true if any of them return true for a rune.
type Range ¶
type Range [2]rune
Range fulfills Matcher returning true when when given a rune that is between the two values (inclusivly).
type Scanner ¶
type Scanner struct { // Str is the string as a byte slice Str []byte // I is the index of the current rune I int // Count is the number of runes read Count int // Rune at the current position Rune rune // Size of the current rune Size int }
Scanner is used it iterate over the runes in a string. Scanner fulfills Iter[rune].
func (*Scanner) Idx ¶
Idx returns the index of the current rune. The index will skip values if there are runes that take multiple bytes.
func (*Scanner) Many ¶
Many checks if the current rune againts m and if it matches iterates until it reaches a rune that does not or reaches the end of the string. The returned bool indicates if it found at least one match.
func (*Scanner) Match ¶
Match checks if the current rune against m and returns the bool. If it is is a match, the Scanner moves to the next value.
type Seperator ¶
type Seperator string
Seperator is used for string operations with a seperator
func (Seperator) BufJoin ¶
BufJoin joins elems making sure there is a single Seperator between each elem and will use buf if it has adequit capacity.
func (Seperator) JoinLen ¶
JoinLen returns the length of joining the elements with a single Seperator. This is used by Join to allocate the correct size slice for the output.
type Strings ¶
type Strings struct { Strings []string Err error Preprocess func(string) (skip bool, cleaned string) NumericReplacer *strings.Replacer // contains filtered or unexported fields }
Strings is helpful when processing a list of strings, often the result of splitting.
func NewStrings ¶
type SubStrings ¶
type SubStrings [][2]uint
SubStrings represents a slice of substrings by index.
func CamelCase ¶
func CamelCase(str string) SubStrings
CamelCase logic is used to split a string into words.
func SubStringBySplit ¶
func SubStringBySplit(splits []int) SubStrings
SubStringBySplit creates a SubStrings slice by splitting the string into sections so that the end of each range is equal to the start of the next.
func TransitionSplit ¶
func TransitionSplit(m Matcher, str string) SubStrings
TransitionSplit takes a Matcher and each place where the result transitions from false to true there is a split.
func (SubStrings) Slice ¶
func (s SubStrings) Slice(str string) []string
Slice applies the SubStrings to str and returns a slice of strings.