Documentation
¶
Overview ¶
Package gstr provides functions for string handling.
Index ¶
- Constants
- func AddSlashes(str string) string
- func CaseCamel(s string) string
- func CaseCamelLower(s string) string
- func CaseDelimited(s string, del byte) string
- func CaseDelimitedScreaming(s string, del uint8, screaming bool) string
- func CaseKebab(s string) string
- func CaseKebabScreaming(s string) string
- func CaseSnake(s string) string
- func CaseSnakeFirstUpper(word string, underscore ...string) string
- func CaseSnakeScreaming(s string) string
- func Contains(str, substr string) bool
- func ContainsAny(s, chars string) bool
- func ContainsI(str, substr string) bool
- func HasPrefix(s, prefix string) bool
- func HasSuffix(s, suffix string) bool
- func IsLetterLower(b byte) bool
- func IsLetterUpper(b byte) bool
- func IsNumeric(s string) bool
- func LcFirst(s string) string
- func Pos(haystack, needle string, startOffset ...int) int
- func PosI(haystack, needle string, startOffset ...int) int
- func PosIRune(haystack, needle string, startOffset ...int) int
- func PosR(haystack, needle string, startOffset ...int) int
- func PosRI(haystack, needle string, startOffset ...int) int
- func PosRIRune(haystack, needle string, startOffset ...int) int
- func PosRRune(haystack, needle string, startOffset ...int) int
- func PosRune(haystack, needle string, startOffset ...int) int
- func QuoteMeta(str string, chars ...string) string
- func Replace(origin, search, replace string, count ...int) string
- func ReplaceByArray(origin string, array []string) string
- func ReplaceByMap(origin string, replaces map[string]string) string
- func ReplaceI(origin, search, replace string, count ...int) string
- func ReplaceIByArray(origin string, array []string) string
- func ReplaceIByMap(origin string, replaces map[string]string) string
- func StripSlashes(str string) string
- func Trim(str string, characterMask ...string) string
- func TrimAll(str string, characterMask ...string) string
- func TrimLeft(str string, characterMask ...string) string
- func TrimLeftStr(str string, cut string, count ...int) string
- func TrimRight(str string, characterMask ...string) string
- func TrimRightStr(str string, cut string, count ...int) string
- func TrimStr(str string, cut string, count ...int) string
- func UcFirst(s string) string
Constants ¶
const (
// NotFoundIndex is the position index for string not found in searching functions.
NotFoundIndex = -1
)
Variables ¶
This section is empty.
Functions ¶
func CaseCamelLower ¶ added in v0.9.8
CaseCamelLower converts a string to lowerCamelCase.
func CaseDelimited ¶ added in v0.9.8
CaseDelimited converts a string to snake.case.delimited.
func CaseDelimitedScreaming ¶ added in v0.9.8
CaseDelimitedScreaming converts a string to DELIMITED.SCREAMING.CASE or delimited.screaming.case.
func CaseKebabScreaming ¶ added in v0.9.8
CaseKebabScreaming converts a string to KEBAB-CASE-SCREAMING.
func CaseSnakeFirstUpper ¶ added in v0.9.8
CaseSnakeFirstUpper converts a string like "RGBCodeMd5" to "rgb_code_md5". TODO for efficiency should change regexp to traversing string in future.
func CaseSnakeScreaming ¶ added in v0.9.8
CaseSnakeScreaming converts a string to SNAKE_CASE_SCREAMING.
func ContainsAny ¶
ContainsAny reports whether any Unicode code points in `chars` are within `s`.
func IsLetterLower ¶ added in v0.9.8
IsLetterLower checks whether the given byte b is in lower case.
func IsLetterUpper ¶ added in v0.9.8
IsLetterUpper checks whether the given byte b is in upper case.
func LcFirst ¶ added in v0.9.8
LcFirst returns a copy of the string s with the first letter mapped to its lower case.
func Pos ¶
Pos returns the position of the first occurrence of `needle` in `haystack` from `startOffset`, case-sensitively. It returns -1, if not found.
func PosI ¶
PosI returns the position of the first occurrence of `needle` in `haystack` from `startOffset`, case-insensitively. It returns -1, if not found.
func PosIRune ¶
PosIRune acts like function PosI but considers `haystack` and `needle` as unicode string.
func PosR ¶
PosR returns the position of the last occurrence of `needle` in `haystack` from `startOffset`, case-sensitively. It returns -1, if not found.
func PosRI ¶
PosRI returns the position of the last occurrence of `needle` in `haystack` from `startOffset`, case-insensitively. It returns -1, if not found.
func PosRIRune ¶
PosRIRune acts like function PosRI but considers `haystack` and `needle` as unicode string.
func PosRRune ¶
PosRRune acts like function PosR but considers `haystack` and `needle` as unicode string.
func PosRune ¶
PosRune acts like function Pos but considers `haystack` and `needle` as unicode string.
func QuoteMeta ¶
QuoteMeta returns a version of str with a backslash character (\) before every character that is among: .\+*?[^]($)
func Replace ¶
Replace returns a copy of the string `origin` in which string `search` replaced by `replace` case-sensitively.
func ReplaceByArray ¶
ReplaceByArray returns a copy of `origin`, which is replaced by a slice in order, case-sensitively.
func ReplaceByMap ¶
ReplaceByMap returns a copy of `origin`, which is replaced by a map in unordered way, case-sensitively.
func ReplaceI ¶
ReplaceI returns a copy of the string `origin` in which string `search` replaced by `replace` case-insensitively.
func ReplaceIByArray ¶
ReplaceIByArray returns a copy of `origin`, which is replaced by a slice in order, case-insensitively.
func ReplaceIByMap ¶
ReplaceIByMap returns a copy of `origin`, which is replaced by a map in unordered way, case-insensitively.
func StripSlashes ¶
StripSlashes un-quotes a quoted string by AddSlashes.
func Trim ¶
Trim strips whitespace (or other characters) from the beginning and end of a string. The optional parameter `characterMask` specifies the additional stripped characters.
func TrimLeftStr ¶
TrimLeftStr strips all the given `cut` string from the beginning of a string. Note that it does not strip the whitespaces of its beginning.
func TrimRightStr ¶
TrimRightStr strips all the given `cut` string from the end of a string. Note that it does not strip the whitespaces of its end.
Types ¶
This section is empty.