Documentation
¶
Index ¶
- Variables
- func Contains(s, substr []rune) bool
- func ContainsAny(s []rune, chars string) bool
- func ContainsRune(s []rune, r rune) bool
- func Count(s, substr []rune) int
- func Cut(s, sep []rune) (before, after []rune, found bool)
- func Equal(a, b []rune) bool
- func EqualFold(s, t []rune) bool
- func Fields(s []rune) [][]rune
- func FieldsFunc(s []rune, f func(rune) bool) [][]rune
- func HasPrefix(s, prefix []rune) bool
- func HasSuffix(s, suffix []rune) bool
- func Index(s, sep []rune) int
- func IndexAny(s []rune, chars string) int
- func IndexByte(s []rune, c byte) int
- func IndexFunc(s []rune, f func(rune) bool) int
- func IndexRune(s []rune, r rune) int
- func Join(s [][]rune, sep []rune) []rune
- func LastIndex(s, sep []rune) int
- func LastIndexAny(s, chars []rune) int
- func LastIndexFunc(s []rune, f func(rune) bool) int
- func LastIndexRune(s []rune, c rune) int
- func Map(mapping func(rune) rune, s []rune) []rune
- func ReadString(runs []rune, offset int, limit int) (string, error)
- func Repeat(b []rune, count int) []rune
- func Replace(s, old, new []rune, n int) []rune
- func ReplaceAll(s, old, new []rune) []rune
- func Split(s, sep []rune) [][]rune
- func SplitAfter(s, sep []rune) [][]rune
- func SplitAfterN(s, sep []rune, n int) [][]rune
- func SplitN(s, sep []rune, n int) [][]rune
- func Title(s []rune) []runedeprecated
- func ToLower(s []rune) []rune
- func ToLowerSpecial(c unicode.SpecialCase, s []rune) []rune
- func ToTitle(s []rune) []rune
- func ToTitleSpecial(c unicode.SpecialCase, s []rune) []rune
- func ToUpper(s []rune) []rune
- func ToUpperSpecial(c unicode.SpecialCase, s []rune) []rune
- func ToValidUTF8(s, replacement []rune) []rune
- func Trim(s []rune, cutset string) []rune
- func TrimFunc(s []rune, f func(rune) bool) []rune
- func TrimLeft(s []rune, cutset string) []rune
- func TrimLeftFunc(s []rune, f func(rune) bool) []rune
- func TrimPrefix(s, prefix []rune) []rune
- func TrimRight(s []rune, cutset string) []rune
- func TrimRightFunc(s []rune, f func(rune) bool) []rune
- func TrimSpace(s []rune) []rune
- func TrimSuffix(s, suffix []rune) []rune
- type Runes
Constants ¶
This section is empty.
Variables ¶
var ErrTooLarge = errors.New("runes.Runes: number is too large than length")
Functions ¶
func ContainsAny ¶
ContainsAny reports whether any Unicode code points in chars are within s.
func ContainsRune ¶
ContainsRune reports whether the Unicode code point r is within s.
func Count ¶
Count counts the number of non-overlapping instances of substr in s. If substr is an empty []rune, Count returns 1 + the number of Unicode code points in s.
func 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.
func Equal ¶
Equal reports whether a and b are the same length and contain the same runes. A nil argument is equivalent to an empty slice.
func EqualFold ¶
EqualFold reports whether s and t, interpreted as UTF-8 []runes, are equal under simple Unicode case-folding, which is a more general form of case-insensitivity.
func Fields ¶
Fields splits the []rune s around each instance of one or more consecutive white space characters, as defined by unicode.IsSpace, returning a slice of sub[]runes of s or an empty slice if s contains only white space.
func FieldsFunc ¶
FieldsFunc splits the []rune s at each run of Unicode code points c satisfying f(c) and returns an array of slices of s. If all code points in s satisfy f(c) or the []rune is empty, an empty slice is returned.
FieldsFunc makes no guarantees about the order in which it calls f(c) and assumes that f always returns the same value for a given c.
func Index ¶
Index returns the index of the first instance of substr in s, or -1 if substr is not present in s.
func IndexAny ¶
IndexAny returns the index of the first instance of any Unicode code point from chars in s, or -1 if no Unicode code point from chars is present in s.
func IndexByte ¶
IndexByte returns the index of the first instance of c in s, or -1 if c is not present in s.
func IndexFunc ¶
IndexFunc returns the index into s of the first Unicode code point satisfying f(c), or -1 if none do.
func IndexRune ¶
IndexRune returns the index of the first instance of the runes point r, or -1 if rune is not present in s.
func Join ¶
Join concatenates the elements of its first argument to create a single []rune. The separator []rune sep is placed between elements in the resulting []rune.
func LastIndex ¶
LastIndex returns the index of the last instance of substr in s, or -1 if substr is not present in s.
func LastIndexAny ¶
LastIndexAny returns the index of the last instance of any Unicode code point from chars in s, or -1 if no Unicode code point from chars is present in s.
func LastIndexFunc ¶
LastIndexFunc returns the index into s of the last Unicode code point satisfying f(c), or -1 if none do.
func LastIndexRune ¶
LastIndexRune returns the index of the last instance of c in s, or -1 if c is not present in s.
func Map ¶
Map returns a copy of the []rune s with all its characters modified according to the mapping function. If mapping returns a negative value, the character is dropped from the []rune with no replacement.
func Repeat ¶
Repeat returns a new []rune consisting of count copies of the []rune s.
It panics if count is negative or if the result of (len(s) * count) overflows.
func Replace ¶
Replace returns a copy of the []rune s with the first n non-overlapping instances of old replaced by new. If old is empty, it matches at the beginning of the []rune and after each UTF-8 sequence, yielding up to k+1 replacements for a k-rune []rune. If n < 0, there is no limit on the number of replacements.
func ReplaceAll ¶
ReplaceAll returns a copy of the []rune s with all non-overlapping instances of old replaced by new. If old is empty, it matches at the beginning of the []rune and after each UTF-8 sequence, yielding up to k+1 replacements for a k-rune []rune.
func Split ¶
Split slices s into all sub[]runes separated by sep and returns a slice of the sub[]runes between those separators.
If s does not contain sep and sep is not empty, Split returns a slice of length 1 whose only element is s.
If sep is empty, Split splits after each UTF-8 sequence. If both s and sep are empty, Split returns an empty slice.
It is equivalent to SplitN with a count of -1.
To split around the first instance of a separator, see Cut.
func SplitAfter ¶
SplitAfter slices s into all sub[]runes after each instance of sep and returns a slice of those sub[]runes.
If s does not contain sep and sep is not empty, SplitAfter returns a slice of length 1 whose only element is s.
If sep is empty, SplitAfter splits after each UTF-8 sequence. If both s and sep are empty, SplitAfter returns an empty slice.
It is equivalent to SplitAfterN with a count of -1.
func SplitAfterN ¶
SplitAfterN slices s into sub[]runes after each instance of sep and returns a slice of those sub[]runes.
The count determines the number of sub[]runes to return:
n > 0: at most n sub[]runes; the last sub[]rune will be the unsplit remainder. n == 0: the result is nil (zero sub[]runes) n < 0: all sub[]runes
Edge cases for s and sep (for example, empty []runes) are handled as described in the documentation for SplitAfter.
func SplitN ¶
SplitN slices s into sub[]runes separated by sep and returns a slice of the sub[]runes between those separators.
The count determines the number of sub[]runes to return:
n > 0: at most n sub[]runes; the last sub[]rune will be the unsplit remainder. n == 0: the result is nil (zero sub[]runes) n < 0: all sub[]runes
Edge cases for s and sep (for example, empty []runes) are handled as described in the documentation for Split.
To split around the first instance of a separator, see Cut.
func ToLowerSpecial ¶
func ToLowerSpecial(c unicode.SpecialCase, s []rune) []rune
ToLowerSpecial returns a copy of the []rune s with all Unicode letters mapped to their lower case using the case mapping specified by c.
func ToTitle ¶
ToTitle returns a copy of the []rune s with all Unicode letters mapped to their Unicode title case.
func ToTitleSpecial ¶
func ToTitleSpecial(c unicode.SpecialCase, s []rune) []rune
ToTitleSpecial returns a copy of the []rune s with all Unicode letters mapped to their Unicode title case, giving priority to the special casing rules.
func ToUpperSpecial ¶
func ToUpperSpecial(c unicode.SpecialCase, s []rune) []rune
ToUpperSpecial returns a copy of the []rune s with all Unicode letters mapped to their upper case using the case mapping specified by c.
func ToValidUTF8 ¶
ToValidUTF8 returns a copy of the []rune s with each run of invalid UTF-8 byte sequences replaced by the replacement []rune, which may be empty.
func Trim ¶
Trim returns a subslice of s by slicing off all leading and trailing UTF-8-encoded code points contained in cutset.
func TrimFunc ¶
TrimFunc returns a slice of the []rune s with all leading and trailing Unicode code points c satisfying f(c) removed.
func TrimLeft ¶
TrimLeft returns a subslice of s by slicing off all leading UTF-8-encoded code points contained in cutset.
func TrimLeftFunc ¶
TrimLeftFunc returns a slice of the []rune s with all leading Unicode code points c satisfying f(c) removed.
func TrimPrefix ¶
TrimPrefix returns s without the provided leading prefix []rune. If s doesn't start with prefix, s is returned unchanged.
func TrimRight ¶
TrimRight returns a slice of the []rune s, with all trailing Unicode code points contained in cutset removed.
To remove a suffix, use TrimSuffix instead.
func TrimRightFunc ¶
TrimRightFunc returns a slice of the []rune s with all trailing Unicode code points c satisfying f(c) removed.
func TrimSpace ¶
TrimSpace returns a slice of the []rune s, with all leading and trailing white space removed, as defined by Unicode.
func TrimSuffix ¶
TrimSuffix returns s without the provided trailing suffix []rune. If s doesn't end with suffix, s is returned unchanged.