exstrings

package
v0.4.43 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bytes

func Bytes(s string) []byte

Bytes 将 string 转换为 []byte

func Capitalize

func Capitalize(s string) string

Capitalize convert first letter to upper and others remain

func ContainsAny added in v0.4.27

func ContainsAny(s string, ss ...string) bool

ContainsAny returns true if s contains any specified substring

func ContainsOnly

func ContainsOnly(s, chars string) bool

func CountNonEmpty

func CountNonEmpty(ss ...string) (c int)

CountNonEmpty 返回非空字符串的个数

func Cut

func Cut(s, sep string) (before, after string, found bool)

Cut slices s around the first instance of sep, returning the text before and after sep. The found result reports whether sep appears in s. If sep does not appear in s, cut returns s, "", false.

Port from Go 1.18 https://cs.opensource.google/go/go/+/refs/tags/go1.18beta1:src/strings/strings.go;l=1177

func DeDuplicate

func DeDuplicate(base []string) []string

func DeepSplit

func DeepSplit(s string) []string

func DeepSplits

func DeepSplits(ss []string) []string

func Diff

func Diff(cmp, base []string) (add, sub, equal []string)

Diff 给出两个数组,返回二者的差异 返回值 1 为 cmp 比 base 增加的元素 返回值 2 为 cmp 比 base 减少的元素 这一函数的时间和空间复杂度均为 O(M+N)

func FirstLine

func FirstLine(s string) string

func FoldSpace

func FoldSpace(s string) string

FoldSpace replace any spaces (more than two) to one space

func GetIntersection

func GetIntersection(sliceList ...[]string) []string

func InStringList

func InStringList(list []string, want string) bool

func LeftPad added in v0.4.26

func LeftPad(s, pad string, c int) string

func LeftPadSpace added in v0.4.26

func LeftPadSpace(s string, minLength int) string

func ListToInt

func ListToInt(ss []string) ([]int, error)

ListToInt 将 []string 转换为 []int, 忽略前后空格

func ListToInterface

func ListToInterface(ss []string) []interface{}

ListToInterface 将 []string 转换为 []interface

func Merge

func Merge(list ...[]string) []string

func PopInStringList

func PopInStringList(list []string, want string) (bool, []string)

PopInStringList 如果元素在列表中,则返回 true 与删除元素后的列表,否则返回 false 与原列表

func RightPad

func RightPad(s, pad string, c int) string

RightPad 使用另一个字符串从右端填充字符串为指定长度。

func RightPadSpace

func RightPadSpace(s string, minLength int) string

func ToReader

func ToReader(s string) io.Reader

func TrimEmptyLine

func TrimEmptyLine(s string) string

TrimEmptyLine 将字符串首尾的空行删除

func UnsafeToBytes

func UnsafeToBytes(s string) []byte

UnsafeToBytes 将 string 转换为 []byte,避免拷贝导致的内存开销 需要注意的是,如果试图对返回的 []byte 进行修改可能会导致程序直接崩溃

Types

This section is empty.

Jump to

Keyboard shortcuts

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