strings

package module
v0.0.0-...-be6a8e8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 14, 2019 License: MIT Imports: 2 Imported by: 0

README

strings

Additional string parsing functions for golang.

installation

Add "github.com/vedranvuk/strings" to import clause for auto install on compile,

or

go get -u github.com/vedranvuk/strings

to install it manually.

Documentation

Overview

Package strings adds additional string utility functions.

Index

Constants

View Source
const (
	Nums       = "0123456789"
	AlphaUpper = "ABCDEFGHIJKLMNOPQRSTUVXYZ"
	AlphaLower = "abcdefghijklmnopqrstuvxyz"
	Alpha      = AlphaUpper + AlphaLower
	AlphaNums  = Nums + Alpha
)
View Source
const DefSpecialChars = " !\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~"

Default special characters set used in passwords. < and > may cause issues on some systems.

Variables

This section is empty.

Functions

func Compare

func Compare(a, b string) int

Compare strings a and b, return -1 if a is lower, 1 if greater, 0 if equal. Case sensitive.

func CompareFold

func CompareFold(a, b string) int

Compare strings a and b, return -1 if a is lower, 1 if greater, 0 if equal. Case in-sensitive.

func ContainsOther

func ContainsOther(s, set string) bool

Checks if string "s" contains characters not in "set".

func FetchLeft

func FetchLeft(s, sep string) string

Return everything from left of "s" up to "sep".

func FetchLeftFold

func FetchLeftFold(s, sep string) string

Return everything from left of "s" up to "sep". Case-insensitive.

func FetchRight

func FetchRight(s, sep string) string

Return everything from "sep" up to end of "s".

func FetchRightFold

func FetchRightFold(s, sep string) string

Return everything from "sep" up to end of "s". Case-insensitive.

func HasPrefixFold

func HasPrefixFold(s, prefix string) bool

HasPrefixFold tests whether the string "s" begins with "prefix". Case-insensitive.

func HasSuffixFold

func HasSuffixFold(s, suffix string) bool

HasSuffixFold tests whether the string "s" ends with "suffix" Case-insensitive.

func Indexes

func Indexes(s, sep string) (r []int)

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

func IndexesFold(s, sep string) []int

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

func IsAlphaLowerOnly(s string) bool

Checks if "s" consists exclusively of lowercase alpha characters.

func IsAlphaNumsOnly

func IsAlphaNumsOnly(s string) bool

Checks if "s" consists exclusively of alphanumeric characters.

func IsAlphaOnly

func IsAlphaOnly(s string) bool

Checks if "s" consists exclusively of alpha characters.

func IsAlphaUpperOnly

func IsAlphaUpperOnly(s string) bool

Checks if "s" consists exclusively of uppercase alpha characters.

func IsNumsOnly

func IsNumsOnly(s string) bool

Checks if "s" consists exclusively of numeric characters.

func LeftByRune

func LeftByRune(s string, count int) string

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

func LenLimitByRune(text string, max int) string

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

func LenSplitByRune(text string, max int) (out []string)

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

func MatchesWildcard(text, pattern string) bool

Matches "text" against "pattern". Case insensitive. * and ? supported.

func MidByRune

func MidByRune(s string, start, count int) string

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 RandomLower

func RandomLower() string

Returns a string containing a random lowercase letter.

func RandomLowers

func RandomLowers(length int) string

Returns a string of random lowercase letters of "length".

func RandomNum

func RandomNum() string

Returns a string containing a random number.

func RandomNums

func RandomNums(length int) string

Returns a string of random numbers of "length".

func RandomSpecial

func RandomSpecial() string

Returns a string containing a random password special character.

func RandomSpecials

func RandomSpecials(length int) string

Returns a string of random special characters of "length".

func RandomString

func RandomString(lo, up, nums bool, length int) string

Returns a random string of "length". If "lo" includes lowercase letters. If "up" includes uppercase letters. If "num" includes numbers.

func RandomUpper

func RandomUpper() string

Returns a string containing a random uppercase letter.

func RandomUppers

func RandomUppers(length int) string

Returns a string of random uppercase letters of "length".

func RightByRune

func RightByRune(s string, count int) string

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 RuneCount

func RuneCount(s string) (n int)

Returns number of runes in the string "s".

func Runes

func Runes(s string) (result []rune)

Returns a slice of runes which form string "s".

func RunesAsStrings

func RunesAsStrings(s string) (result []string)

Explodes "s" into an array of runes in a string array.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL