stringx

package
v0.0.0-...-02246d9 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2023 License: BSD-3-Clause Imports: 13 Imported by: 7

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Contains

func Contains(s string, ss []string, caseSensitive bool) bool

func ContainsChinese

func ContainsChinese(str string) bool

func EndsWith

func EndsWith(s string, ss []string, caseSensitive bool) bool

func HexToByte

func HexToByte(hex string) []byte

HexToByte 16进制字符串转 []byte Like pack("H*", string) in PHP

func IsBlank

func IsBlank(s string) bool

func IsEmpty

func IsEmpty(s string) bool

IsEmpty 判断字符串是否为空

func Len

func Len(s string) int

Len 获取字符串长度(一个中文算 1)

func LowerFirst

func LowerFirst(s string) string

LowerFirst 首字母小写

func QuoteMeta

func QuoteMeta(s string) string

func RemoveEmoji

func RemoveEmoji(str string, trim bool) string

RemoveEmoji 清理 Emoji 表情

func RemoveExtraSpace

func RemoveExtraSpace(s string) string

RemoveExtraSpace 移除多余的空格

func SequentialWordFields

func SequentialWordFields(s string, n int, separators ...string) []string

SequentialWordFields 将 s 字符串根据指定的分隔符分隔为 1 - n 个连续单词组合的词组 单词前后的非字母和数字将会移除掉(比如 help? 将会变成 help),单词中间的则不会处理(a?b 包含在单词中间的 ? 不会处理)

stringx.SequentialWordFields("this is a string, are you sure?", 1, ",") => ["this", "is", "a", "string", "are", "you", "sure"] stringx.SequentialWordFields("this is a string, are you sure?", 2, ",") => ["this", "is", "a", "string", "are", "you", "sure", "this is", "is a", "a string", "are you", "you sure"]

func Split

func Split(str string, separators ...string) []string

Split split word by special seps, use empty string if seps is empty

func StartsWith

func StartsWith(s string, ss []string, caseSensitive bool) bool

func String

func String(value interface{}) string

func ToBytes

func ToBytes(s string) []byte

func ToNarrow

func ToNarrow(str string) string

ToNarrow Full width string to half width

func ToWiden

func ToWiden(str string) string

ToWiden Half with string to full width

func TrimAny

func TrimAny(s string, sets ...string) string

TrimAny 移除头部和尾部指定的内容

func UpperFirst

func UpperFirst(s string) string

UpperFirst 首字母大写

func WordMatched

func WordMatched(s string, words []string, caseSensitive bool) bool

WordMatched 判断 s 中是否包含指定的 words 单词 对于英文必须是单词形式,比如 he 不能匹配 hello world,只能匹配 hello|world 如果是中文的话,则会使用 Index 进行判断,不等于 -1 则判断为匹配

Types

This section is empty.

Jump to

Keyboard shortcuts

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