bzstr

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	JoinAnyStructKV  = joinAnyStruct{/* contains filtered or unexported fields */}
	JoinAnyStructAll = joinAnyStruct{/* contains filtered or unexported fields */}
)

Functions

func AsciiChar

func AsciiChar(i int) string

func AsciiNum

func AsciiNum(s string) (int, error)

func Contains

func Contains(s, substr string) bool

func ContainsIgnore

func ContainsIgnore(s, substr string) bool

func Count

func Count(s string, substr string) int

Count 统计字符在字符串中出现的次数 Count(s string, substr string) int @param s string 字符串 @param substr string 统计字符 @return int 出现的次数

func CountChar

func CountChar(s string) map[string]int

CountChar 统计每个字符在字符串中出现的次数 CountIgnore(s string) map[string]int @param s string 字符串 @return map[string]int 字符和出现的次数

func CountIgnore

func CountIgnore(s string, substr string) int

CountIgnore 统计字符在字符串中出现的次数,忽略大小写 CountIgnore(s string, substr string) int @param s string 字符串 @param substr string 统计字符 @return int 出现的次数

func Cut

func Cut(s, start, end string) string

func FilterIDNumber

func FilterIDNumber(idNumber string) string

FilterIDNumber 过滤身份证号码

func FilterName

func FilterName(name string) string

FilterName 过滤姓名 FilterName(name string) string @param name string 需要过滤的姓名 @return string 过滤后的姓名

func FilterWithMarkFirstAndLast

func FilterWithMarkFirstAndLast(s, tag string) string

func FilterWithMarkRetainFirstN

func FilterWithMarkRetainFirstN(s, tag string, n int) string

func FilterWithMarkRetainLastN

func FilterWithMarkRetainLastN(s, tag string, n int) string

func FilterWithMarkRetainN

func FilterWithMarkRetainN(s, tag string, firstN, lastN int) string

func Index

func Index(s, substr string) int

func IndexIgnore

func IndexIgnore(s, substr string) int

func IndexRune

func IndexRune(s string, r rune) int

func IndexRuneAny

func IndexRuneAny(s string, r rune) int

func IsEmpty

func IsEmpty(s string) bool

IsEmpty 判断字符串是否为空 IsEmpty(s string) bool @param s string 字符串 @return bool 是否为空

func IsLower

func IsLower(s string) bool

IsLower 判断字符串是否为小写 IsLower(s string) bool @param s string 字符串 @return bool 是否为小写

func IsNotEmpty

func IsNotEmpty(s string) bool

IsNotEmpty 判断字符串是否不为空 IsNotEmpty(s string) bool @param s string 字符串 @return bool 是否不为空

func IsNumeric

func IsNumeric(s string) bool

IsNumeric 判断字符串是否数字 IsNumeric(s string) bool @param s string 字符串 @return bool 是否数字

func IsUpper

func IsUpper(s string) bool

IsUpper 判断字符串是否为大写 IsUpper(s string) bool @param s string 字符串 @return bool 是否为大写

func Join

func Join(s []string, sep string) string

Join 将切片合并为字符串 Join(s []string, sep string) string @param s []string 字符串切片 @param sep string 拼接字符 @return string 合并后的字符串

func JoinAny

func JoinAny[T any](s []T, sep string, typs ...joinAnyStruct) string

JoinAny 将切片合并为字符串 JoinAny[T any](s []T, sep string, typ joinAnyType) string @param s []string 字符串切片 @param sep string 拼接字符 @param typs ...joinAnyStruct 结构体格式化可选类型:默认仅输出值、JoinAnyStructKV输出字段和值、JoinAnyStructAll输出完整结构体 @return string 合并后的字符串

func JoinVal

func JoinVal[T bztype.Numeric | bool](s []T, sep string) string

JoinVal 将切片合并为字符串 JoinVal[T bztype.Numeric | bool](s []T, sep string) string @param s []string 数值或布尔值切片 @param sep string 拼接字符 @return string 合并后的字符串

func RandStr

func RandStr(n int) string

func Repeat

func Repeat(s string, repeatTimes int) string

Repeat 得到指定字符重复n次的字符串 Repeat(s string, repeatTimes int) string @param s string 字符串 @param repeatTimes int 重复次数 @return string 结果字符串

func Replace

func Replace(s, old, new string, n ...int) string

func ReplaceAllByMap

func ReplaceAllByMap(s string, m map[string]string) string

func ReplaceAllWithBraceByMap

func ReplaceAllWithBraceByMap(s string, m map[string]string) string

ReplaceAllWithBraceByMap 花括号解析

func ReplaceAllWithSquareBraceByMap

func ReplaceAllWithSquareBraceByMap(s string, m map[string]string) string

ReplaceAllWithSquareBraceByMap 方括号解析

func Reverse

func Reverse(s string) string

func RuneLen

func RuneLen(s string) int

RuneLen 计算unicode字符串长度 RuneLen(s string) int @param s string 字符串 @return int 长度

func Split

func Split(s string, sep string) []string

Split 切分字符串 Split(s string, sep string) []string @param s string 字符串 @param sep string 分割字符 @return []string 切分后的字符串切片

func SplitN

func SplitN(s string, sep string, n int) []string

SplitN 切分字符串为N份 SplitN(s string, sep string) []string @param s string 字符串 @param sep string 分割字符 @param n int 切片结果的数量 @return []string 切分后的字符串切片

func SplitRetain

func SplitRetain(s string, sep string) []string

SplitRetain 切分字符串并保留分割字符 SplitRetain(s string, sep string) []string @param s string 字符串 @param sep string 分割字符 @return []string 切分后的字符串切片

func SplitRetainN

func SplitRetainN(s string, sep string, n int) []string

SplitRetainN 切分字符串为N份并保留分割字符 SplitRetainN(s string, sep string) []string @param s string 字符串 @param sep string 分割字符 @param n int 切片结果的数量 @return []string 切分后的字符串切片

func Substr

func Substr(s string, start int, length ...int) string

func ToByte

func ToByte(s string) []byte

ToByte 字符串转[]byte ToByte(s string) []byte @param s string 字符串 @return []byte 转换的[]byte结果

func ToDecimal

func ToDecimal(num float64, i int) string

func ToFloat

func ToFloat(s string) (float64, error)

ToFloat 字符串转float ToFloat(s string) (float64, error) @param s string 字符串 @return float64 转换的float结果 @return error 错误信息

func ToInt

func ToInt(s string) (int64, error)

ToInt 字符串转int ToInt(s string) (int64, error) @param s string 字符串 @return int64 转换的int结果 @return error 错误信息

func ToLower

func ToLower(s string) string

ToLower 将字符串转为小写 ToLower(s string) string @param s string 字符串 @return string 小写字符串结果

func ToLowerFirst

func ToLowerFirst(s string) string

ToLowerFirst 将字符串首字符转为小写 ToLowerFirst(s string) string @param s string 字符串 @return string 首字符小写字符串结果

func ToUpper

func ToUpper(s string) string

ToUpper 将字符串转为大写 ToUpper(s string) string @param s string 字符串 @return string 大写字符串结果

func ToUpperFirst

func ToUpperFirst(s string) string

ToUpperFirst 将字符串首字符转为大写 ToUpperFirst(s string) string @param s string 字符串 @return string 首字符大写字符串结果

func ToUpperWords

func ToUpperWords(s string) string

ToUpperWords 将字符串每个单词首字符转为大写 ToUpper(s string) string @param s string 字符串 @return string 字符串结果

func Utf8Encode

func Utf8Encode(s string) string

Types

This section is empty.

Jump to

Keyboard shortcuts

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