str

package
v1.0.1005 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Addslashes

func Addslashes(str string) string

Addslashes

func Bin2hex

func Bin2hex(str string) (string, error)

Bin2hex

func Bindec

func Bindec(str string) (string, error)

Bindec

func Camel

func Camel(str string) string

Camel 转为 CamelCase

func Chr

func Chr(ascii int) string

Chr

func CompareVersion

func CompareVersion(src, toCompare string) bool

版本比对

func Contains

func Contains(s string, str string) int

比对

func ContainsLast

func ContainsLast(s string, str string) int

最后比对

func ContainsRune

func ContainsRune(s string, ch rune) int

非ASCII编码子字符

func Delimited

func Delimited(s string, delimiter uint8) string

转为 delimited.snake.case

func Empty

func Empty(val any) bool

判断是否为空

func Explode

func Explode(delimiter, str string) []string

Explode

func HTMLEntityDecode

func HTMLEntityDecode(str string) string

HTMLEntityDecode

func Hex2bin

func Hex2bin(data string) (string, error)

Hex2bin

func Htmlentities

func Htmlentities(str string) string

Htmlentities

func IsNil

func IsNil(i any) bool

判断是否为 nil

func IsNumeric

func IsNumeric(val any) bool

是否为数字

func JSONDecode

func JSONDecode(data string, val any) error

JSONDecode

func JSONEncode

func JSONEncode(val any) string

转换为 json 字符

func Kebab

func Kebab(s string) string

转为 kebab-case

func Lcfirst

func Lcfirst(str string) string

Lcfirst

func LowerCamel

func LowerCamel(str string) string

LowerCamel 转为 lowerCamelCase

func MbStrlen

func MbStrlen(str string) int

MbStrlen

func Nl2br

func Nl2br(str string, isXhtml bool) string

Nl2br \n\r, \r\n, \r, \n

func Ord

func Ord(char string) int

Ord

func PadBoth

func PadBoth(value string, length int, pad string) string

填充字符串的两侧

func PadLeft

func PadLeft(value string, length int, pad string) string

填充字符串的左侧

func PadRight

func PadRight(value string, length int, pad string) string

填充字符串的右侧

func Random

func Random(n int, allowedChars ...[]rune) string

生成随机数

func Repeat

func Repeat(str string, times int) string

重复

func Replace

func Replace(search string, replace string, subject string) string

替换

func ReplaceNth

func ReplaceNth(s, old, new string, n int) string

func ScreamingDelimited

func ScreamingDelimited(s string, delimiter uint8, ignore string, screaming bool) string

ScreamingDelimited

func ScreamingKebab

func ScreamingKebab(s string) string

转为 SCREAMING-KEBAB-CASE

func ScreamingSnake

func ScreamingSnake(s string) string

转为 SCREAMING_SNAKE_CASE

func Snake

func Snake(str string) string

Snake 转为 snake_case

func SnakeWithIgnore

func SnakeWithIgnore(s string, ignore string) string

SnakeWithIgnore 分割线自定义

func StrShuffle

func StrShuffle(str string) string

StrShuffle

func StrWordCount

func StrWordCount(str string) []string

StrWordCount

func StringsJoin

func StringsJoin(strs ...string) string

字符串拼接

func Stripos

func Stripos(haystack string, needle string, start ...int) int

判断位置

func Stripslashes

func Stripslashes(str string) string

Stripslashes

func Strlen

func Strlen(str string) int

Strlen

func Strpos

func Strpos(haystack string, needle string, start ...int) int

判断位置

func Strrev

func Strrev(str string) string

Strrev

func Strripos

func Strripos(haystack string, needle string, start ...int) int

Strripos

func Strrpos

func Strrpos(haystack string, needle string, start ...int) int

Strrpos

func Strstr

func Strstr(haystack string, needle string) string

Strstr

func Strtr

func Strtr(haystack string, params ...any) string

Strtr("baab", "ab", "01") will return "1001", a => 0; b => 1.

func Strval

func Strval(value any) string

非数值或字符类型的变量将会被转换成JSON格式字符串

func Substr

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

返回字符串的子串

func ToASCII

func ToASCII(str string) string

转为 ASCII

func ToLower

func ToLower(str string) string

小写

func ToUnicode

func ToUnicode(str string) string

转为 Unicode 字符

func ToUpper

func ToUpper(str string) string

大写

func Ucfirst

func Ucfirst(str string) string

Ucfirst

func Ucwords

func Ucwords(str string) string

Ucwords

func UnicodeTo

func UnicodeTo(str string) (string, error)

转出

func Uniqid

func Uniqid(prefix string) string

唯一 ID

Types

type S

type S string

*

  • 字符串类型转换 *
  • @create 2021-8-28
  • @author deatil

func NewS

func NewS(b []byte) S

func (S) Bool

func (this S) Bool() (bool, error)

转换为bool

func (S) Bytes

func (this S) Bytes() []byte

转换为[]byte

func (S) DefaultBool

func (this S) DefaultBool(defaultVal bool) bool

转换为bool,如果出现错误则使用默认值

func (S) DefaultFloat32

func (this S) DefaultFloat32(defaultVal float32) float32

转换为float32,如果出现错误则使用默认值

func (S) DefaultFloat64

func (this S) DefaultFloat64(defaultVal float64) float64

转换为float64,如果出现错误则使用默认值

func (S) DefaultInt

func (this S) DefaultInt(defaultVal int) int

转换为int,如果出现错误则使用默认值

func (S) DefaultInt64

func (this S) DefaultInt64(defaultVal int64) int64

转换为int64,如果出现错误则使用默认值

func (S) DefaultUint

func (this S) DefaultUint(defaultVal uint) uint

转换为uint,如果出现错误则使用默认值

func (S) DefaultUint64

func (this S) DefaultUint64(defaultVal uint64) uint64

转换为uint64,如果出现错误则使用默认值

func (S) Float32

func (this S) Float32() (float32, error)

转换为float32

func (S) Float64

func (this S) Float64() (float64, error)

转换为float64

func (S) GetParentDir

func (this S) GetParentDir() string

获取父级目录

func (S) Int

func (this S) Int() (int, error)

转换为int

func (S) Int64

func (this S) Int64() (int64, error)

转换为int64

func (S) String

func (this S) String() string

func (S) Substr

func (this S) Substr(pos, length int) string

截取

func (S) ToJSON

func (this S) ToJSON(v any) error

转换为JSON

func (S) Uint

func (this S) Uint() (uint, error)

转换为uint

func (S) Uint64

func (this S) Uint64() (uint64, error)

转换为uint64

Jump to

Keyboard shortcuts

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