gstr

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2022 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// DefaultTrimChars are the characters which are stripped by Trim* functions in default.
	DefaultTrimChars = string([]byte{
		'\t',
		'\v',
		'\n',
		'\r',
		'\f',
		' ',
		0x00,
		0x85,
		0xA0,
	})
)

Functions

func AddSlashes

func AddSlashes(str string) string

AddSlashes quotes chars('"\) with slashes.

func Contains

func Contains(str, substr string) bool

Contains reports whether <substr> is within <str>, case-sensitively.

func ContainsAny

func ContainsAny(s, chars string) bool

ContainsAny reports whether any Unicode code points in <chars> are within <s>.

func ContainsI

func ContainsI(str, substr string) bool

ContainsI reports whether substr is within str, case-insensitively.

func IsNumeric

func IsNumeric(s string) bool

IsNumeric tests whether the given string s is numeric.

func Parse

func Parse(s string) (result map[string]interface{}, err error)

Parse parses the string into map[string]interface{}.

v1=m&v2=n -> map[v1:m v2:n] v[a]=m&v[b]=n -> map[v:map[a:m b:n]] v[a][a]=m&v[a][b]=n -> map[v:map[a:map[a:m b:n]]] v[]=m&v[]=n -> map[v:[m n]] v[a][]=m&v[a][]=n -> map[v:map[a:[m n]]] v[][]=m&v[][]=n -> map[v:[map[]]] // Currently does not support nested slice. v=m&v[a]=n -> error a .[[b=c -> map[a___[b:c]

func PosI

func PosI(haystack, needle string, startOffset ...int) int

PosI returns the position of the first occurrence of <needle> in <haystack> from <startOffset>, case-insensitively. It returns -1, if not found.

func QuoteMeta

func QuoteMeta(str string, chars ...string) string

QuoteMeta returns a version of str with a backslash character (\) before every character that is among: .\+*?[^]($)

func Replace

func Replace(origin, search, replace string, count ...int) string

Replace returns a copy of the string `origin` in which string `search` replaced by `replace` case-sensitively.

func SplitAndTrim

func SplitAndTrim(str, delimiter string, characterMask ...string) []string

SplitAndTrim splits string `str` by a string `delimiter` to an array, and calls Trim to every element of this array. It ignores the elements which are empty after Trim.

func StripSlashes

func StripSlashes(str string) string

StripSlashes un-quotes a quoted string by AddSlashes.

func Trim

func Trim(str string, characterMask ...string) string

Trim strips whitespace (or other characters) from the beginning and end of a string. The optional parameter <characterMask> specifies the additional stripped characters.

func TrimAll

func TrimAll(str string, characterMask ...string) string

TrimAll trims all characters in string `str`.

func TrimLeft

func TrimLeft(str string, characterMask ...string) string

TrimLeft strips whitespace (or other characters) from the beginning of a string.

func TrimLeftStr

func TrimLeftStr(str string, cut string, count ...int) string

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 TrimRight

func TrimRight(str string, characterMask ...string) string

TrimRight strips whitespace (or other characters) from the end of a string.

func TrimRightStr

func TrimRightStr(str string, cut string, count ...int) string

TrimRightStr strips all the given <cut> string from the end of a string. Note that it does not strip the whitespaces of its end.

func TrimStr

func TrimStr(str string, cut string, count ...int) string

TrimStr strips all the given <cut> string from the beginning and end of a string. Note that it does not strip the whitespaces of its beginning or end.

Types

This section is empty.

Jump to

Keyboard shortcuts

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