match

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2024 License: LGPL-3.0 Imports: 5 Imported by: 2

Documentation

Index

Constants

View Source
const (
	CmpStringOmit            = iota // 不比较
	CmpStringContains               // 包含
	CmpStringStartswith             // 打头
	CmpStringEndswith               // 结尾
	CmpStringIgnoreSpaces           // 忽略空格
	CmpStringCaseInsensitive        // 不分大小写
	CmpStringEqual                  // 相等
)

字符串比较方式

Variables

This section is empty.

Functions

func InStringList

func InStringList(x string, lst []string) bool

InStringList 是否在字符串列表中

func IsDigit

func IsDigit(s string) bool

IsDigit 是否纯数字

func IsSubsetList

func IsSubsetList(lst1, lst2 []string, strict bool) bool

IsSubsetList lst1 是否 lst2 的(真)子集

func QuoteColumns

func QuoteColumns(cols []string, sep string, quote func(string) string) string

QuoteColumns 盲转义,认为字段名以小写字母开头

func ReduceSpaces

func ReduceSpaces(s string) string

ReduceSpaces 将多个连续空白缩减为一个空格

func RemoveSpaces

func RemoveSpaces(s string) string

RemoveSpaces 删除所有空白,包括中间的

func ReplaceWith

func ReplaceWith(s string, subs map[string]string) string

ReplaceWith 一一对应进行替换,次序不定(因为map的关系)

func StartStringList

func StartStringList(x string, lst []string) bool

StartStringList 是否在字符串列表中,比较方式是有任何一个开头符合

func StringMatch

func StringMatch(a, b string, cmp int) bool

StringMatch 比较是否相符

func TruncateText

func TruncateText(msg string, size int) string

TruncateText 截断长文本

Types

type Globs

type Globs []glob.Glob

func NewGlobs

func NewGlobs(wildcards []string) Globs

func (Globs) MatchAll

func (g Globs) MatchAll(word string, forEmpty bool) bool

func (Globs) MatchAny

func (g Globs) MatchAny(word string, forEmpty bool) bool

type Word

type Word string

Word 字符串逐个字符匹配

func (Word) MatchSubString

func (w Word) MatchSubString(subs string) (string, Word)

MatchSubString 寻找字符第一次出现的位置,类似IndexAny

func (Word) SkipAnyChar

func (w Word) SkipAnyChar(chars string) Word

SkipAnyChar 忽略开头字符

Jump to

Keyboard shortcuts

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