Documentation
¶
Index ¶
- Variables
- func CutStringToLen(val string, maxLen int) string
- func EscWildcard(source string, addPfx bool) string
- func FirstLower(s string) string
- func FirstUpper(s string) string
- func FlatCase(s string) string
- func InArray(array []string, search string) bool
- func IsAlpha(s string) bool
- func IsDigit(c rune) bool
- func IsLetter(c rune) bool
- func IsNumber(s string) bool
- func IsNumberOrNumberWithSign(s string) bool
- func IsUnicodeLetter(s string) bool
- func LeftPad(s string, padStr string, pLen int) string
- func LeftPad2Len(s string, padStr string, overallLen int) string
- func Match(pattern, name string) (matched bool)
- func MatchAsPatternPrefix(pattern, text string) bool
- func MatchSimple(pattern, name string) bool
- func PascalCase(s string) string
- func PascalSnakeCaseAllFirstUpper(s string) string
- func RemoveDoubleWhiteSpace(str string) string
- func RemoveNonAlphaNumeric(s string) string
- func RemoveUtf8PlAccentsFromQuery(text string) string
- func RemoveWhiteSpaces(s string) string
- func ReplaceAll(s string, newString string, searches ...string) string
- func ReplaceAllPairs(s string, pairs ...Pair) string
- func ReplacePairOfRunes(s string, pairs ...PairOfRunes) string
- func RightPad(s string, padStr string, pLen int) string
- func RightPad2Len(s string, padStr string, overallLen int) string
- func SnakeCaseAllFirstUpper(s string) string
- func SnakeCaseFirstLower(s string) string
- func SnakeCaseFirstUpper(s string) string
- func Split(src string, skip string) (entries []string)
- func SplitQuotedString(text string) (items []string)
- func StripWhiteSpaces(str string) string
- func UnderscoreCase(s string) string
- func UnderscoreCaseLower(s string) string
- func UnderscoreCaseUpper(s string) string
- type Pair
- type PairOfRunes
- type Strings
Constants ¶
This section is empty.
Variables ¶
var PL_UTF8_CHARSET_PAIRS = []PairOfRunes{ PairOfRunes{'ę', 'e'}, PairOfRunes{'ó', 'o'}, PairOfRunes{'ą', 'a'}, PairOfRunes{'ś', 's'}, PairOfRunes{'ł', 'l'}, PairOfRunes{'ż', 'z'}, PairOfRunes{'ź', 'z'}, PairOfRunes{'ć', 'c'}, PairOfRunes{'ń', 'N'}, PairOfRunes{'Ę', 'E'}, PairOfRunes{'Ó', 'O'}, PairOfRunes{'Ą', 'A'}, PairOfRunes{'Ś', 'S'}, PairOfRunes{'Ł', 'L'}, PairOfRunes{'Ż', 'Z'}, PairOfRunes{'Ź', 'Ć'}, PairOfRunes{'Ń', 'N'}, }
Functions ¶
func CutStringToLen ¶
func EscWildcard ¶ added in v1.0.1
func FirstLower ¶
func FirstUpper ¶
func IsUnicodeLetter ¶
func LeftPad ¶
TODO convert these into a
* leftPad and rightPad just repoeat the padStr the indicated * number of times *
func Match ¶
Match - finds whether the text matches/satisfies the pattern string. supports '*' and '?' wildcards in the pattern string. unlike path.Match(), considers a path as a flat name space while matching the pattern. The difference is illustrated in the example here https://play.golang.org/p/Ega9qgD4Qz .
func MatchAsPatternPrefix ¶ added in v1.0.1
MatchAsPatternPrefix matches text as a prefix of the given pattern. Examples:
| Pattern | Text | Match Result | ==================================== | abc* | ab | True | | abc* | abd | False | | abc*c | abcd | True | | ab*??d | abxxc | True | | ab*??d | abxc | True | | ab??d | abxc | True | | ab??d | abc | True | | ab??d | abcxdd | False |
This function is only useful in some special situations.
func MatchSimple ¶
MatchSimple - finds whether the text matches/satisfies the pattern string. supports '*' wildcard in the pattern and ? for single characters. Only difference to Match is that `?` at the end is optional, meaning `a?` pattern will match name `a`.
func PascalCase ¶
zamiana zmienna --> zmienna zmienna_inna ZmiennaInna
func RemoveDoubleWhiteSpace ¶
func RemoveNonAlphaNumeric ¶
func RemoveWhiteSpaces ¶
func ReplaceAllPairs ¶
func ReplacePairOfRunes ¶
func ReplacePairOfRunes(s string, pairs ...PairOfRunes) string
func RightPad2Len ¶
the Pad2Len functions are generally assumed to be padded with short sequences of strings
* in many cases with a single character sequence * * so we assume we can build the string out as if the char seq is 1 char and then * just substr the string if it is longer than needed * * this means we are wasting some cpu and memory work * but this always get us to want we want it to be * * in short not optimized to for massive string work * * If the overallLen is shorter than the original string length * the string will be shortened to this length (substr) *
func SnakeCaseAllFirstUpper ¶
func SnakeCaseFirstLower ¶
zamiana: zmienna -> zmienna zmiennaInna -> zmiennaInna ZmiennnaInnaDruga -> zmiennaInnaDruga Zmienna1 Zmienna2 -> zmienna1Zmienna2
func SnakeCaseFirstUpper ¶
zamiana: zmienna -> Zmienna zmiennaInna -> ZmiennaInna ZmiennnaInnaDruga -> ZmiennaInnaDruga Zmienna1 Zmienna2 -> Zmienna1Zmienna2
func Split ¶
Split splits the camelcase word and returns a list of words. It also supports digits. Both lower camel case and upper camel case are supported. For more info please check: http://en.wikipedia.org/wiki/CamelCase
Examples
"" => [""] "lowercase" => ["lowercase"] "Class" => ["Class"] "MyClass" => ["My", "Class"] "MyC" => ["My", "C"] "HTML" => ["HTML"] "PDFLoader" => ["PDF", "Loader"] "AString" => ["A", "String"] "SimpleXMLParser" => ["Simple", "XML", "Parser"] "vimRPCPlugin" => ["vim", "RPC", "Plugin"] "GL11Version" => ["GL", "11", "Version"] "99Bottles" => ["99", "Bottles"] "May5" => ["May", "5"] "BFG9000" => ["BFG", "9000"] "BöseÜberraschung" => ["Böse", "Überraschung"] "Two spaces" => ["Two", " ", "spaces"] "BadUTF8\xe2\xe2\xa1" => ["BadUTF8\xe2\xe2\xa1"]
Splitting rules
- If string is not valid UTF-8, return it without splitting as single item array.
- Assign all unicode characters into one of 4 sets: lower case letters, upper case letters, numbers, and all other characters.
- Iterate through characters of string, introducing splits between adjacent characters that belong to different sets.
- Iterate through array of split strings, and if a given string is upper case: if subsequent string is lower case: move last character of upper case string to beginning of lower case string
func SplitQuotedString ¶
func StripWhiteSpaces ¶
func UnderscoreCase ¶
zamiana: zmienna -> zmienna zmiennaInna -> zmienna_Inna ZmiennnaInnaDruga -> Zmienna_Inna_Drug
func UnderscoreCaseLower ¶
zamiana: zmienna -> zmienna zmiennaInna -> zmienna_inna ZmiennnaInnaDruga -> zmienna_inna_drug
func UnderscoreCaseUpper ¶
zamiana: zmienna -> ZMIENNA zmiennaInna -> ZMIENNA_INNA ZmiennnaInnaDruga -> ZMIENNA_INNA_DRUGA
Types ¶
type PairOfRunes ¶
type Strings ¶
type Strings []string
func (Strings) IsInCaseSensitive ¶
func (Strings) ToInterfaceSlice ¶
func (ss Strings) ToInterfaceSlice() []interface{}