Documentation ¶
Index ¶
- Constants
- func Capitalize(s1 string) string
- func CommonInitialismsMap() map[string]bool
- func CondenseString(content string, join_lines bool) string
- func CondenseStringSimple(s string) string
- func Dedupe(vals []string) []string
- func DigitsOnly(input string) string
- func Equal(str1, str2 string, trim, lower bool) bool
- func FormatString(s string, options []string) string
- func InterfaceToSliceString(s interface{}) []string
- func JoinInterface(arr []interface{}, sep string, stripRepeatedSep bool, stripEmbeddedSep bool, ...) string
- func JoinLiterary(slice []string, sep, joinWord string) string
- func JoinLiteraryQuote(slice []string, leftQuote, rightQuote, sep, joinWord string) string
- func JoinStringsTrimSpaceToLowerSort(strs []string, sep string) string
- func JoinTrimSpace(strs []string) string
- func Match(s string, matchInfo MatchInfo) (bool, error)
- func NewlineToLinux(input string) string
- func PadLeft(str string, pad string, length int) string
- func PadRight(str string, pad string, length int) string
- func Quote(str, beg, end string) string
- func RemoveSpaces(input string) string
- func Slice2FilterLinesHaveIndex(groups [][]string, needle string, wantIndex int) [][]string
- func SliceChooseOnePreferredLowerTrimSpace(options, preferenceOrder []string) string
- func SliceCondenseAndQuote(items []string, trimLeft, trimRight, quoteLeft, quoteRight string) []string
- func SliceCondenseAndQuoteSpace(items []string, quoteLeft, quoteRight string) []string
- func SliceCondensePunctuation(texts []string) []string
- func SliceCondenseRegexps(texts []string, regexps []*regexp.Regexp, replacement string) []string
- func SliceCondenseSpace(lines []string, dedupeResults, sortResults bool) []string
- func SliceIndex(haystack []string, needle string, trimSpace, toLower bool, matchType MatchType) int
- func SliceIndexOrEmpty(s []string, index uint64) string
- func SliceIntersection(list1, list2 []string) []string
- func SliceIntersectionCondenseSpace(slice1, slice2 []string) []string
- func SliceLineHasIndex(haystack []string, needle string, wantIndex int) bool
- func SliceSubtract(real, filter []string) []string
- func SliceToMap(strs []string) map[string]int
- func SliceToSingleIntOrNeg(vals []string) int
- func SliceTrim(lines []string, cutstr string, condense bool) []string
- func SliceTrimSpace(lines []string, condense bool) []string
- func SplitCondenseSpace(s, sep string) []string
- func SplitTextLines(text string) []string
- func SplitTrimSpace(s, sep string) []string
- func StringToConstant(s string) string
- func StripControl(s string) string
- func SubstringIsSuffix(s1, s2 string) bool
- func ToBool(v string) bool
- func ToLowerFirst(s1 string) string
- func ToOpposite(s string) string
- func ToUpperFirst(s1 string, lowerRest bool) string
- func TrimSentenceLength(sentenceInput string, maxLength int) string
- func TrimSpaceWithDefault(str string, defaultValue string) string
- func Unshift(a []string, x string) []string
- func UrlToMarkdownLinkHostname(url string) string
- type MatchInfo
- type MatchType
- type Quoter
- type StrUtil
- type StringSlice
Constants ¶
const ( StringToLower = "StringToLower" SpaceToHyphen = "SpaceToHyphen" SpaceToUnderscore = "SpaceToUnderscore" )
const CommonInitialisms = "" /* 160-byte string literal not displayed */
CommonInitialisms is the listed by Go Lint.
Variables ¶
This section is empty.
Functions ¶
func Capitalize ¶
Capitalize returns a string with the first character capitalized and the rest lower cased.
func CommonInitialismsMap ¶
CommonInitialismsMap returns map[string]bool of upper case initialisms.
func CondenseString ¶
CondenseString trims whitespace at the ends of the string as well as in between.
func CondenseStringSimple ¶
CondenseStringSimple removes extra spaces.
func Dedupe ¶
Dedupe returns a string slice with duplicate values removed. First observance is kept.
func DigitsOnly ¶ added in v1.1.0
func FormatString ¶
func InterfaceToSliceString ¶
func InterfaceToSliceString(s interface{}) []string
func JoinInterface ¶
func JoinInterface(arr []interface{}, sep string, stripRepeatedSep bool, stripEmbeddedSep bool, altSep string) string
JoinInterface joins an interface and returns a string. It takes a join separator, boolean to replace the join separator in the string parts and a separator alternate. `stripEmbeddedSep` strips separator string found within parts. `stripRepeatedSep` strips repeating separators. This flexibility is designed to support joining data for both CSVs and paths.
func JoinLiterary ¶
func JoinLiteraryQuote ¶
func JoinTrimSpace ¶
func NewlineToLinux ¶
func PadLeft ¶
PadLeft prepends a string to a base string until the string length is greater or equal to the desired length.
func PadRight ¶
PadRight appends a string to a base string until the string length is greater or equal to the desired length.
func RemoveSpaces ¶
RemoveSpaces eliminates all spaces in a string.
func SliceCondenseAndQuote ¶
func SliceCondenseRegexps ¶
func SliceCondenseSpace ¶
SliceCondenseSpace trims space from lines and removes empty lines. `unique` dedupes lines and `sort` preforms a sort on the results.
func SliceIndex ¶
SliceIndex returns the index of an element in a string slice. Returns -1 if not found.
func SliceIndexOrEmpty ¶
SliceIndexOrEmpty returns the element at the index provided or an empty string.
func SliceIntersection ¶
func SliceLineHasIndex ¶
func SliceSubtract ¶
SliceSubtract uses Set math to remove elements of filter from real.
func SliceToMap ¶
func SliceToSingleIntOrNeg ¶
SliceToSingleIntOrNeg converts a single element slice with a string to an integer or `-1`
func SliceTrimSpace ¶
SliceTrimSpace removes leading and trailing spaces per string and optionally removes empty strings.
func SplitCondenseSpace ¶
SplitCondenseSpace splits a string and trims spaces on remaining elements, removing empty elements.
func SplitTextLines ¶
SplitTextLines splits a string on the regxp `(\r\n|\r|\n)`.
func SplitTrimSpace ¶
SplitTrimSpace splits a string and trims spaces on remaining elements.
func StringToConstant ¶
StringToConstant is used to generate constant names for code generation. It uses the commonInitialisms in Go Lint.
func StripControl ¶
func SubstringIsSuffix ¶
func ToBool ¶
ToBool converts a string to a boolean value looking for the string "true" in any case.
func ToLowerFirst ¶
ToLowerFirst lower cases the first letter in the string
func ToOpposite ¶
func ToUpperFirst ¶
ToUpperFirst upper cases the first letter in the string
func TrimSentenceLength ¶
TrimSentenceLength trims a string by a max length at word boundaries.
func TrimSpaceWithDefault ¶ added in v1.3.0
TrimSpaceWithDefault trims spaces and replaces default value if result is empty string.
Types ¶
type StrUtil ¶
type StrUtil struct { RxSpaceBeg *regexp.Regexp RxSpaceEnd *regexp.Regexp RxSpacePunct *regexp.Regexp RxDash *regexp.Regexp }
func NewStrUtil ¶
func NewStrUtil() StrUtil
type StringSlice ¶ added in v1.3.0
type StringSlice []string
func (StringSlice) Exists ¶ added in v1.3.0
func (sx StringSlice) Exists(s string) bool