stringsi

package
v1.2.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 6, 2023 License: MIT Imports: 8 Imported by: 1

Documentation

Overview

Match provides a simple pattern matcher with unicode support.

Index

Constants

This section is empty.

Variables

View Source
var HanPunctuation = []rune{
	'\u3002', '\uff1b', '\uff0c', '\uff1a', '\u201c', '\u201d', '\uff08', '\uff09', '\u3001', '\uff1f', '\u300a', '\u300b',
}

[。;,:“”()、?《》]

Functions

func Allowable

func Allowable(pattern string) (min, max string)

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 AnchorName

func AnchorName(text string) string

Create returns a sanitized anchor name for the given text.

func Camel

func Camel(s string) string

func CamelCase

func CamelCase[T ~string](s T) string

func CamelCaseSlice

func CamelCaseSlice(elem []string) string

func CamelToSnake

func CamelToSnake(name string) string

func ConvertToCamelCase

func ConvertToCamelCase(s string) string

func ConvertUnicode

func ConvertUnicode(s []byte) string

func Cut added in v1.1.0

func Cut(s, sep string) (string, string, bool)

func CutPart added in v1.1.0

func CutPart(s, key string) string

指定字符截断,返回阶段前的字符串 CutPart("https://wx1.sinaimg.cn/orj360/6ebedee6ly1h566bbzyc6j20n00cuabd.jpg", "wx1") https://

func FormatLen

func FormatLen(s string, length int) string

func HasHan

func HasHan(s string) bool

func HasPrefixes

func HasPrefixes(s string, prefixes []string) bool

有一个匹配成功就返回true

func In

func In(s string, ss []string) bool

func IsASCIIDigit

func IsASCIIDigit(c byte) bool

Is c an ASCII digit?

func IsASCIILower

func IsASCIILower(c byte) bool

Is c an ASCII lower-case letter?

func IsPattern

func IsPattern(str string) bool

IsPattern returns true if the string is a pattern.

func LowerCase

func LowerCase(c byte) byte

func LowerFirst

func LowerFirst(t string) string

仅首位小写(更符合接口的规范)

func Match

func Match(str, pattern string) bool

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 QuoteToBytes

func QuoteToBytes(s string) []byte

func Rand

func Rand(length int) string

func ReplaceBytesEmpty

func ReplaceBytesEmpty(s string, old ...byte) string

将字符串中指定的ascii字符替换为空

func ReplaceRuneEmpty

func ReplaceRuneEmpty(s string, old ...rune) string

func ReplaceRunesEmpty added in v1.1.0

func ReplaceRunesEmpty(s string, old ...rune) string

notest

func ReverseCut added in v1.1.0

func ReverseCut(s, sep string) (string, string, bool)

func ReverseCutPart added in v1.1.0

func ReverseCutPart(s, key string) string

从字符串尾开始,返回指定字符截断后的字符串 ReverseCutPart("https://video.weibo.com/media/play?livephoto=https%3A%2F%2Flivephoto.us.sinaimg.cn%2F002OnXdGgx07YpcajtkH0f0f0100gv8Q0k01.mov", "%2F") 002OnXdGgx07YpcajtkH0f0f0100gv8Q0k01.mov

func ToBytes

func ToBytes(s string) []byte

func ToString

func ToString(b []byte) string

func Unquote

func Unquote(s []byte) (t string, ok bool)

unquote converts a quoted JSON string literal s into an actual string t. The rules are different than for Go, so cannot use strconv.Unquote.

func UpperCase

func UpperCase(c byte) byte

func UpperCaseFirst

func UpperCaseFirst(t string) string

Types

type NumLetterSlice

type NumLetterSlice[T any] ['z' - '0' + 1]T

func (*NumLetterSlice[T]) Set

func (n *NumLetterSlice[T]) Set(b byte, v T)

原来数组支持这样用

Directories

Path Synopsis
Match provides a simple pattern matcher with unicode support.
Match provides a simple pattern matcher with unicode support.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL