Documentation
¶
Overview ¶
Package strings adds additional string utility functions.
Index ¶
- Constants
- func Compare(a, b string) int
- func CompareFold(a, b string) int
- func ContainsOther(s, set string) bool
- func FetchLeft(s, sep string) string
- func FetchLeftFold(s, sep string) string
- func FetchRight(s, sep string) string
- func FetchRightFold(s, sep string) string
- func HasPrefixFold(s, prefix string) bool
- func HasSuffixFold(s, suffix string) bool
- func Indexes(s, sep string) (r []int)
- func IndexesFold(s, sep string) []int
- func IsAlphaLowerOnly(s string) bool
- func IsAlphaNumsOnly(s string) bool
- func IsAlphaOnly(s string) bool
- func IsAlphaUpperOnly(s string) bool
- func IsNumsOnly(s string) bool
- func LeftByRune(s string, count int) string
- func LenLimitByRune(text string, max int) string
- func LenSplitByRune(text string, max int) (out []string)
- func MatchesWildcard(text, pattern string) bool
- func MidByRune(s string, start, count int) string
- func RandomLower() string
- func RandomLowers(length int) string
- func RandomNum() string
- func RandomNums(length int) string
- func RandomSpecial() string
- func RandomSpecials(length int) string
- func RandomString(lo, up, nums bool, length int) string
- func RandomUpper() string
- func RandomUppers(length int) string
- func RightByRune(s string, count int) string
- func RuneCount(s string) (n int)
- func Runes(s string) (result []rune)
- func RunesAsStrings(s string) (result []string)
Constants ¶
const ( Nums = "0123456789" AlphaUpper = "ABCDEFGHIJKLMNOPQRSTUVXYZ" AlphaLower = "abcdefghijklmnopqrstuvxyz" Alpha = AlphaUpper + AlphaLower AlphaNums = Nums + Alpha )
const DefSpecialChars = " !\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~"
Default special characters set used in passwords. < and > may cause issues on some systems.
Variables ¶
This section is empty.
Functions ¶
func Compare ¶
Compare strings a and b, return -1 if a is lower, 1 if greater, 0 if equal. Case sensitive.
func CompareFold ¶
Compare strings a and b, return -1 if a is lower, 1 if greater, 0 if equal. Case in-sensitive.
func ContainsOther ¶
Checks if string "s" contains characters not in "set".
func FetchLeftFold ¶
Return everything from left of "s" up to "sep". Case-insensitive.
func FetchRight ¶
Return everything from "sep" up to end of "s".
func FetchRightFold ¶
Return everything from "sep" up to end of "s". Case-insensitive.
func HasPrefixFold ¶
HasPrefixFold tests whether the string "s" begins with "prefix". Case-insensitive.
func HasSuffixFold ¶
HasSuffixFold tests whether the string "s" ends with "suffix" Case-insensitive.
func Indexes ¶
Indexes returns a slice of all indexes of "sep" starting byte positions in "s", or an empty slice if none are present in "s".
func IndexesFold ¶
Indexes returns a slice of all indexes of "sep" starting byte positions in "s", or an empty slice if none are present in "s". Case-insensitive.
func IsAlphaLowerOnly ¶
Checks if "s" consists exclusively of lowercase alpha characters.
func IsAlphaNumsOnly ¶
Checks if "s" consists exclusively of alphanumeric characters.
func IsAlphaOnly ¶
Checks if "s" consists exclusively of alpha characters.
func IsAlphaUpperOnly ¶
Checks if "s" consists exclusively of uppercase alpha characters.
func IsNumsOnly ¶
Checks if "s" consists exclusively of numeric characters.
func LeftByRune ¶
Returns "count" runes from left side of string "s" as a string. If "count" is more than num of chars in "s" all is returned w/o error.
func LenLimitByRune ¶
Limits "text" to "max" length which is expressed in bytes. Limiting is done at UTF-8 unicode code points and resulting string is ensured to be less than or equal to "max" bytes in length.
func LenSplitByRune ¶
Split "msg" to array of string of "max" length which is expressed in bytes. Splitting is done at UTF-8 unicode cod points and resulting strings are ensured to be less than or equal to "max" bytes in length.
func MatchesWildcard ¶
Matches "text" against "pattern". Case insensitive. * and ? supported.
func MidByRune ¶
Returns "count" runes from left "offset" side of string "s" as a string. If "count" is more than num of chars in "s" all is returned w/o error.
func RandomLowers ¶
Returns a string of random lowercase letters of "length".
func RandomNums ¶
Returns a string of random numbers of "length".
func RandomSpecial ¶
func RandomSpecial() string
Returns a string containing a random password special character.
func RandomSpecials ¶
Returns a string of random special characters of "length".
func RandomString ¶
Returns a random string of "length". If "lo" includes lowercase letters. If "up" includes uppercase letters. If "num" includes numbers.
func RandomUppers ¶
Returns a string of random uppercase letters of "length".
func RightByRune ¶
Returns "count" runes from right side of string "s" as a string. If "count" is more than num of chars in "s" all is returned w/o error.
func RunesAsStrings ¶
Explodes "s" into an array of runes in a string array.
Types ¶
This section is empty.