Documentation
¶
Overview ¶
Match provides a simple pattern matcher with unicode support.
Index ¶
- func Allowable(pattern string) (min, max string)
- func BracketsIntervals(s string, tokenBegin, tokenEnd rune) (string, bool)
- func BytesFrom(p unsafe.Pointer, n int, c int) (r []byte)
- func BytesToString(b []byte) string
- func CamelCase(s string) string
- func CamelCaseSlice(elem []string) string
- func CamelToSnake(name string) string
- func CommonRuneHandler(s string, rm func(r rune) bool) string
- func CommonRuneReplace(s string, f func(r rune) rune) string
- func Cut(s, sep string) (string, string, bool)
- func CutPart(s, sep string) string
- func CutPartContain(s, sep string) string
- func DJB33(seed uint32, k string) uint32
- func FormatLen(s string, length int) string
- func FromBytes(b []byte) string
- func HasPrefixes(s string, prefixes []string) bool
- func IndexByte(ptr []byte, index int) unsafe.Pointer
- func IndexChar(src string, index int) unsafe.Pointer
- func IsEmpty(str string) bool
- func IsNumber(str string) bool
- func IsPattern(str string) bool
- func IsQuoted[T ~string | ~[]byte](s T) bool
- func Join[S ~[]T, T fmt.Stringer](s S, sep string) string
- func JoinFunc[S ~[]T, T any](s S, toString func(idx int, v T) string, sep string) string
- func JoinIndexFunc[S ~[]T, T any](s S, toString func(i int) string, sep string) string
- func JoinValueFunc[S ~[]T, T any](s S, toString func(v T) string, sep string) string
- func LowerCase(c byte) byte
- func LowerCaseFirst(t string) string
- func Match(str, pattern string) bool
- func Mem2Str(v []byte) (s string)
- func Rand(length int) string
- func RemoveEmoji(s string) string
- func RemoveRunes(s string, old ...rune) string
- func RemoveSymbol(s string) string
- func ReplaceBytes(s string, olds []byte, new byte) string
- func ReplaceBytesEmpty(s string, old ...byte) string
- func ReplaceRunes(s string, olds []rune, new rune) string
- func RetainHanAndASCII(s string) string
- func RetainHanAndASCIIGt32(s string) string
- func ReverseCut(s, sep string) (string, string, bool)
- func ReverseCutPart(s, key string) string
- func SimpleQuote(s string) string
- func SimpleQuoteToBytes(s string) []byte
- func SnakeToCamel[T ~string](s T) string
- func SplitCamelCase(src string) (entries []string)
- func Str2Mem(s string) (v []byte)
- func StrFrom(p unsafe.Pointer, n int64) (s string)
- func StrPtr(s string) unsafe.Pointer
- func StringToBytes(s string) []byte
- func ToBytes(s string) []byte
- func UpperCase(c byte) byte
- func UpperCaseFirst(t string) string
- type NumLetterSlice
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Allowable ¶ added in v1.7.6
Allowable parses the pattern and determines the minimum and maximum allowable values that the pattern can represent. When the max cannot be determined, 'true' will be returned for infinite.
func BracketsIntervals ¶
寻找括号区间 BracketsIntervals 在给定字符串中寻找由特定开始和结束符号包围的区间。 它会返回第一个找到的由tokenBegin和tokenEnd界定的字符串区间, 如果找到了则返回该区间和true,否则返回空字符串和false。
参数: s - 待搜索的字符串。 tokenBegin - 搜索的开始符号。 tokenEnd - 搜索的结束符号。
返回值: 第一个找到的由tokenBegin和tokenEnd界定的字符串区间, 如果找到了则返回该区间和true,否则返回空字符串和false。
func BytesToString ¶
func CamelCase ¶
CamelCase camel-cases a protobuf name for use as a Go identifier.
If there is an interior underscore followed by a lower case letter, drop the underscore and convert the letter to upper case.
func CamelCaseSlice ¶
func CamelToSnake ¶
func CutPart ¶
指定字符截断,返回阶段前的字符串 CutPart("https://wx1.sinaimg.cn/orj360/6ebedee6ly1h566bbzyc6j20n00cuabd.jpg", "wx1") https://
func CutPartContain ¶
指定字符截断,返回阶段前加指定字符的字符串 CutPartContain("https://f.video.weibocdn.com/o0/F9Nmm1ZJlx080UxqxlJK010412004rJS0E010.mp4?label=mp4_hd&template=540x960.24.0&ori=0&ps=1CwnkDw1GXwCQx&Expires=1670569613&ssig=fAQcBh4HGt&KID=unistore,video", "mp4") https://f.video.weibocdn.com/o0/F9Nmm1ZJlx080UxqxlJK010412004rJS0E010.mp4
func JoinIndexFunc ¶ added in v1.7.0
func JoinValueFunc ¶ added in v1.7.0
func Match ¶ added in v1.7.6
pattern:
{ term }
term:
'*' matches any sequence of non-Separator characters '?' matches any single non-Separator character c matches character c (c != '*', '?', '\\') '\\' c matches character c
func RemoveEmoji ¶
func RemoveRunes ¶
func RemoveSymbol ¶
func RetainHanAndASCII ¶
func RetainHanAndASCIIGt32 ¶
func ReverseCutPart ¶
从字符串尾开始,返回指定字符截断后的字符串 ReverseCutPart("https://video.weibo.com/media/play?livephoto=https%3A%2F%2Flivephoto.us.sinaimg.cn%2F002OnXdGgx07YpcajtkH0f0f0100gv8Q0k01.mov", "%2F") 002OnXdGgx07YpcajtkH0f0f0100gv8Q0k01.mov
func SimpleQuote ¶ added in v1.3.18
func SimpleQuoteToBytes ¶ added in v1.3.18
func SnakeToCamel ¶
func SplitCamelCase ¶
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", "Chinese"] "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 StringToBytes ¶
func UpperCaseFirst ¶
Types ¶
type NumLetterSlice ¶
type NumLetterSlice[T any] ['z' - '0' + 1]T