Documentation ¶
Index ¶
- Constants
- func Capitalize(s1 string) string
- func CommonInitialismsMap() map[string]bool
- func CondenseSpace(s string) string
- func CondenseString(content string, joinLines bool) string
- func ContainsMore(s string, substrs []string, all, lc, trimSpaceSubstr bool) bool
- func Dedupe(elems []string) []string
- func DigitsOnly(input string) string
- func EmptyError(s string, err error) string
- func EndsWith(s string, substrs ...string) bool
- func Equal(str1, str2 string, trim, lower bool) bool
- func EqualFoldFull(s, t string, caser *cases.Caser) bool
- func FirstNonEmpty(vals ...string) string
- func FirstNotEmptyTrimSpace(candidates ...string) string
- func FormatString(s string, options []string) string
- func IfBoolString(boolVal bool, valueA, valueB string) string
- func IndexMulti(s string, substr ...string) int
- func InterfaceToSliceString(s interface{}) []string
- func IsAlpha(s string) bool
- func IsAlphaNumeric(s string) bool
- func IsNumeric(s string) bool
- 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 Matrix2DColRowIndex(mat [][]string, colIdx uint, s string) (int, 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 Reverse(s string) string
- func ReverseIndex(s, substr string) int
- func Slice2FilterLinesHaveIndex(groups [][]string, needle string, wantIndex int) [][]string
- func SliceBySplitLength(elems []string, sep string) map[int][]string
- func SliceChooseOnePreferredLowerTrimSpace(options, preferenceOrder []string) string
- func SliceCondenseAndQuote(items []string, trimLeft, trimRight, quoteLeft, quoteRight string) []string
- func SliceCondenseAndQuoteSpace(elems []string, quoteLeft, quoteRight string) []string
- func SliceCondensePunctuation(elems []string) []string
- func SliceCondenseRegexps(elems []string, regexps []*regexp.Regexp, replacement string) []string
- func SliceCondenseSpace(elems []string, dedupeResults, sortResults bool) []string
- func SliceDedupe(elems []string) []string
- func SliceIndex(haystack []string, needle string, equalFold bool, caser *cases.Caser) int
- func SliceIndexContains(s []string, substr string) int
- func SliceIndexMore(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 SliceIsEmpty(elems []string, skipEmptyStrings bool) bool
- func SliceLineHasIndex(haystack []string, needle string, wantIndex int) bool
- func SliceSplitLengthStats(elems []string, sep string) map[int]int
- func SliceSubtract(real, filter []string) []string
- func SliceToMap(elems []string) map[string]int
- func SliceToSingleIntOrNeg(vals []string) int
- func SliceTrim(elems []string, cutstr string, condense bool) []string
- func SliceTrimSpace(elems []string, condense bool) []string
- func SlicesCompare(sliceA, sliceB []string) ([]string, []string, []string)
- func SplitCondenseSpace(s, sep string) []string
- func SplitLines(s string) []string
- func SplitTextLines(text string) []string
- func SplitTrimSpace(s, sep string) []string
- func StringToConstant(s string) string
- func StripControl(s string) string
- func StripSubstring(s, substr string, insensitive bool) string
- func SubstringIsSuffix(s1, s2 string) bool
- func SuffixMap(inputs, suffixes []string) (prefixes []string, matches map[string]string, nonmatches []string)
- func SuffixParse(s, wantSuffix string) (fullstring, prefix, suffix string)
- func SuffixReplace(s, oldSuffix, newSuffix string) string
- func SuffixStrip(s, suffix string) string
- func ToBool(v string) bool
- func ToLineFeeds(s string) string
- 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 TrimSpaceOrDefault(str, defaultValue string) string
- func URLToMarkdownLinkHostname(url string) string
- func Unshift(elems []string, x string) []string
- type MatchInfo
- type MatchType
- type Quoter
- type StrUtil
- type StringSlice
- type Stringable
- type StringableWithErr
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 ContainsMore ¶ added in v0.34.4
func Dedupe ¶
Dedupe returns a string slice with duplicate values removed. First observance is kept.
func DigitsOnly ¶
func EmptyError ¶ added in v0.36.2
EmptyError takes a string and error, returning the string value or an empty string if an error is encountered. It is used for simplifying code that returns a value or an error if not present.
func EqualFoldFull ¶ added in v0.41.5
EqualFoldFull provides "full Unicode case-folding", unlike `strings.EqualFold` which provides "simple Unicode case-folding". If `caser` is set to `nil`, the default caser with no additional `cases.Option` is used.
func FirstNonEmpty ¶
func FirstNotEmptyTrimSpace ¶
FirstNotEmptyTrimSpace returns the first non-empty string after applying `strings.TrimSpace()`.`
func FormatString ¶
func IfBoolString ¶
func IndexMulti ¶ added in v0.37.7
IndexMulti returns the earliest match.
func InterfaceToSliceString ¶
func InterfaceToSliceString(s interface{}) []string
func IsAlphaNumeric ¶ added in v0.41.0
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 Matrix2DColRowIndex ¶ added in v0.40.3
Matrix2DColRowIndex returns the row index where the string supplied is first encountered for a supplied column index.
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 Reverse ¶
Reverse reverses string using strings.Builder. It's about 3 times faster than the one with using a string concatenation
func ReverseIndex ¶
ReverseIndex returns the `Index` after reversing the supplied string and substring.
func SliceBySplitLength ¶
SliceBySplitLength returns lines by split length. This is useful for analyzing what types of data exist with different lengths.
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 SliceDedupe ¶ added in v0.36.4
SliceDedupe removes duplicate occurrences of a string from a slice, keeping the first one encountered. It maintains the order of elements in the slice.
func SliceIndex ¶
SliceIndex returns the index of the first match using `=`. Returns -1 if not found. if `equalFold` is selected and `caser` is `nil`, the default caser will be used.
func SliceIndexContains ¶ added in v0.36.1
SliceIndexContains returns the index of the first match using `strings.Contains()`. Returns -1 if not found.
func SliceIndexMore ¶
func SliceIndexMore(haystack []string, needle string, trimSpace, toLower bool, matchType MatchType) int
SliceIndexMore 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 SliceIsEmpty ¶
SliceIsEmpty checks to see if a slice is empty. If `skipEmptyStrings` it will also return empty if all elements are empty strings or only contain spaces.
func SliceLineHasIndex ¶
func SliceSplitLengthStats ¶
SliceSplitLengthStats returns a `map[int]int` indicating how many strings of which length are present.
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. If condense is used, empty strings are removed.
func SlicesCompare ¶
SlicesCompare returns 3 slices given 2 slices which represent intersection sets. The first set is present in slice A but not B, second for both and third present in slice B but not A.
func SplitCondenseSpace ¶
SplitCondenseSpace splits a string and trims spaces on remaining elements, removing empty elements.
func SplitLines ¶
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 StripSubstring ¶ added in v0.36.1
func SubstringIsSuffix ¶
func SuffixParse ¶ added in v0.41.0
func SuffixReplace ¶ added in v0.41.0
func SuffixStrip ¶ added in v0.41.0
func ToBool ¶
ToBool converts a string to a boolean value converting "f", "false", "0" and the empty string to false with everything else being true.
func ToLineFeeds ¶
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 TrimSpaceOrDefault ¶
TrimSpaceOrDefault trims spaces and replaces default value if result is empty string.
func URLToMarkdownLinkHostname ¶ added in v0.37.0
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 ¶
type StringSlice []string
func (StringSlice) Exists ¶
func (sx StringSlice) Exists(s string) bool
type Stringable ¶ added in v0.39.4
type Stringable interface {
String() string
}