Documentation
¶
Overview ¶
Copyright 2015 Huan Du. All rights reserved. Licensed under the MIT license that can be found in the LICENSE file. https://github.com/huandu/xstrings
@Author: qida
@LastEditors: qida
@Author: qida
@LastEditors: qida
Copyright 2015 Huan Du. All rights reserved. Licensed under the MIT license that can be found in the LICENSE file. https://github.com/huandu/xstrings
Index ¶
- Constants
- Variables
- func AESGCMDecrypt(key, ciphertext []byte) ([]byte, error)
- func AESGCMEncrypt(key, plaintext []byte) ([]byte, error)
- func AmountConvert(p_money float64, p_Round bool) string
- func ByteSliceToString(bytes []byte) string
- func Camel2Case(name string) string
- func CamelString(s string) string
- func Case2Camel(name string) string
- func DBCtoSBC(s string) string
- func Expand(template string, match map[string]string, subs ...string) string
- func FirstRuneToLower(str string) string
- func FirstRuneToUpper(str string) string
- func GetKeyWordType(key_word string) (type_word int8)
- func GetKeysString(key_str string) (number int, py string, han string)
- func IsLetter(l uint8) bool
- func Lcfirst(str string) string
- func NumReg(han string) int
- func RandomCreateBytes(n int, alphabets ...byte) []byte
- func RemoveRepeatJoin(src string, dst string) string
- func Reverse(s string) string
- func Show_substr(s string, l int) string
- func Shuffle(str string) string
- func ShuffleSource(str string, src rand.Source) string
- func SnakeString(s string) string
- func StringToByteSlice(s string) []byte
- func Sub(str string, start, length int) string
- func SubString(str string, begin, length int) (substr string)
- func Substr(str string, start int, length int) string
- func Substr2(str string, start int, end int) string
- func SubstrByByte(str string, length int) string
- func Successor(str string) string
- func SwapCase(str string) string
- func ToCamelCase(str string) string
- func ToKebabCase(str string) string
- func ToSnakeCase(str string) string
- func Ucfirst(str string) string
- func UnicodeIndex(str, substr string) int
- func VersionToInt(version string) int
- type Buffer
- type JsonCamelCase
- type JsonSnakeCase
- type Range
- type Trie
- type TrieOption
Constants ¶
const ( Type未知 = 0 Type数字 = 1 Type手机 = 2 Type字母 = 2 Type汉字 = 3 Type身份 = 4 )
Variables ¶
var StateNames = [...]string{"⌛", "🟢", "🟡", "🔴"}
Functions ¶
func AESGCMDecrypt ¶
AESGCMDecrypt decrypts ciphertext with the given key using AES in GCM mode.
func AESGCMEncrypt ¶
AESGCMEncrypt encrypts plaintext with the given key using AES in GCM mode.
func AmountConvert ¶
func CamelString ¶
*
- 蛇形转驼峰
- @description xx_yy to XxYx xx_y_y to XxYY
- @param s要转换的字符串
- @return string *
func FirstRuneToLower ¶
FirstRuneToLower converts first rune to lower case if necessary.
func FirstRuneToUpper ¶
FirstRuneToUpper converts first rune to upper case if necessary.
func GetKeyWordType ¶
func RandomCreateBytes ¶
RandomCreateBytes generate random []byte by specify chars.
func RemoveRepeatJoin ¶
func Show_substr ¶
func Shuffle ¶
Shuffle randomizes runes in a string and returns the result. It uses default random source in `math/rand`.
func ShuffleSource ¶
ShuffleSource randomizes runes in a string with given random source.
func SnakeString ¶
*
- 驼峰转蛇形 snake string
- @description XxYy to xx_yy , XxYY to xx_y_y
- @param s 需要转换的字符串
- @return string *
func Successor ¶
Successor returns the successor to string.
If there is one alphanumeric rune is found in string, increase the rune by 1. If increment generates a "carry", the rune to the left of it is incremented. This process repeats until there is no carry, adding an additional rune if necessary.
If there is no alphanumeric rune, the rightmost rune will be increased by 1 regardless whether the result is a valid rune or not.
Only following characters are alphanumeric.
- a - z
- A - Z
- 0 - 9
Samples (borrowed from ruby's String#succ document):
"abcd" => "abce" "THX1138" => "THX1139" "<<koala>>" => "<<koalb>>" "1999zzz" => "2000aaa" "ZZZ9999" => "AAAA0000" "***" => "**+"
func ToCamelCase ¶
ToCamelCase is to convert words separated by space, underscore and hyphen to camel case.
Some samples.
"some_words" => "SomeWords" "http_server" => "HttpServer" "no_https" => "NoHttps" "_complex__case_" => "_Complex_Case_" "some words" => "SomeWords"
func ToKebabCase ¶
ToKebabCase can convert all upper case characters in a string to kebab case format.
Some samples.
"FirstName" => "first-name" "HTTPServer" => "http-server" "NoHTTPS" => "no-https" "GO_PATH" => "go-path" "GO PATH" => "go-path" // space is converted to '-'. "GO-PATH" => "go-path" // hyphen is converted to '-'. "http2xx" => "http-2xx" // insert an underscore before a number and after an alphabet. "HTTP20xOK" => "http-20x-ok" "Duration2m3s" => "duration-2m3s" "Bld4Floor3rd" => "bld4-floor-3rd"
func ToSnakeCase ¶
ToSnakeCase can convert all upper case characters in a string to snake case format.
Some samples.
"FirstName" => "first_name" "HTTPServer" => "http_server" "NoHTTPS" => "no_https" "GO_PATH" => "go_path" "GO PATH" => "go_path" // space is converted to underscore. "GO-PATH" => "go_path" // hyphen is converted to underscore. "http2xx" => "http_2xx" // insert an underscore before a number and after an alphabet. "HTTP20xOK" => "http_20x_ok" "Duration2m3s" => "duration_2m3s" "Bld4Floor3rd" => "bld4_floor_3rd"
func UnicodeIndex ¶
Types ¶
type JsonCamelCase ¶
type JsonCamelCase struct {
Value interface{}
}
************************************** 驼峰json **************************************
func (JsonCamelCase) MarshalJSON ¶
func (c JsonCamelCase) MarshalJSON() ([]byte, error)
type JsonSnakeCase ¶
type JsonSnakeCase struct {
Value interface{}
}
************************************** 下划线json **************************************
func (JsonSnakeCase) MarshalJSON ¶
func (c JsonSnakeCase) MarshalJSON() ([]byte, error)
type Trie ¶
type Trie interface { Filter(text string) (string, []string, bool) FindKeywords(text string) []string }
A Trie is a tree implementation that used to find elements rapidly.
type TrieOption ¶
type TrieOption func(trie *trieNode)
TrieOption defines the method to customize a Trie.
func WithMask ¶
func WithMask(mask rune) TrieOption
WithMask customizes a Trie with keywords masked as given mask char.