Documentation ¶
Overview ¶
Package strutil provides utility functions for working with strings.
Index ¶
- func ContainsWord(str, word string) bool
- func ExtractVariables(v string) (map[string]bool, error)
- func Filter(in []string, p func(string) bool) []string
- func FilterNonEmpty(in []string) []string
- func FilterStringsByPrefix(in []string, prefix string) []string
- func IsImageURL(src string) bool
- func IsURL(v string) bool
- func JoinNonEmpty(in []string, separator string) string
- func QuoteSplit(str, separator string, stripQuotes bool) []string
- func ReplaceVariables(v string, args map[string]string) (string, error)
- func SliceOnlyContains(list []string, s string) bool
- func ToTitle(str string) string
- func ToURL(fragment, domain string) string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ContainsWord ¶
ContainsWord returns true if the string contains the (space-separated) full word.
func ExtractVariables ¶
ExtractVariables returns a map of variable names found within an input string.
func FilterNonEmpty ¶
FilterNonEmpty returns the string list with empty strings removed.
func FilterStringsByPrefix ¶
FilterStringsByPrefix filters returns only strings that do NOT have a given prefix.
func IsImageURL ¶
IsImageURL returns true if the format of the string appears to be a URL image.
func JoinNonEmpty ¶
JoinNonEmpty filters empty strings and joins remainder together.
func QuoteSplit ¶
QuoteSplit is similiar to strings.Split() but doesn't split within double-quotes.
func ReplaceVariables ¶
ReplaceVariables replaces all substrings of the form "${var-name}" based on args like {"var-name":"var-value"}.
func SliceOnlyContains ¶ added in v0.8.9
SliceOnlyContains checks if the string slice only contains the given string.
Types ¶
This section is empty.