str

package
v0.0.0-...-57ed434 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2023 License: AGPL-3.0 Imports: 15 Imported by: 7

Documentation

Index

Constants

View Source
const (
	// 定义换行符
	EOF = '\x03' // 结束字符
	NL  = '\n'
	CR  = '\r'
	EOL = '\n'
)

Variables

This section is empty.

Functions

func ArrayDiff

func ArrayDiff(arr1, arr2 []string) (diffArr []string)

ArrayDiff 对比,获取在 arr1 中存在,但在 arr2 中不存在的元素集合

func CheckStrInArray

func CheckStrInArray(strArray []string, target string) bool

CheckStrInArray 判断字符串是否字符串切片中

func CountStrByGBK

func CountStrByGBK(str string) int

func DeleteSliceElement

func DeleteSliceElement(array []string, elem string) []string

DeleteSliceElement 删除指定字符串元素

func GetCardCommentRealWords

func GetCardCommentRealWords(comment string) string

获取过滤掉@成员的 字符

func GetTruncatedComment

func GetTruncatedComment(comment string, limitWords int, userIds []int64) string

GetTruncatedComment 评论字数截断,不包含@成员的字数 卫忠实现的 暂时没用。

func InArray

func InArray(needle string, strSlice []string) bool

元素为 string 的 slice 版本的 InArray 函数

func Int64Implode

func Int64Implode(list []int64, glue string) string

Int64Implode 将切片内容拼接成字符串

func Last

func Last(str string, n int) string

func LcFirst

func LcFirst(str string) string

func ParseOssKey

func ParseOssKey(url string) string

func RenderAtSomeoneStr

func RenderAtSomeoneStr(openId, userName string) string

用于拼接飞书得 at 标签

func ReplaceWhiteSpaceCharToSpace

func ReplaceWhiteSpaceCharToSpace(str string) string

ReplaceWhiteSpaceCharToSpace 将空白字符替换为一个空格

func RuneLen

func RuneLen(s string) int

func Substr

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

start:正数 - 在字符串的指定位置开始,超出字符串长度强制把start变为字符串长度

负数 - 在从字符串结尾的指定位置开始
0 - 在字符串中的第一个字符处开始

length:正数 - 从 start 参数所在的位置返回

负数 - 从字符串末端返回

func ToInt64

func ToInt64(dest interface{}) (int64, error)

func ToPtr

func ToPtr(s string) *string

ToPtr 字符串转指针

func ToString

func ToString(dest interface{}) string

func TrimComment

func TrimComment(str string) string

去除评论@的标签

func TrimHtml

func TrimHtml(src string) string

func TruncateColumnName

func TruncateColumnName(column lc_table.LcCommonField) string

TruncateColumnName 飞书卡片中,列名部分的截断处理

func TruncateName

func TruncateName(name string, limit int) string

func TruncateText

func TruncateText(text string, count int) string

TruncateText 截断文本 count 保留的字符个数

func UrlParse

func UrlParse(url string) (string, string)

Types

type CutCommentObj

type CutCommentObj struct {
	Src     string
	SrcRune []rune
	Offset  int
	Line    int
	Col     int
	Total   int // src 总长度
	IsPeek  bool
	Ch      rune
}

CutCommentObj 按照要求解析评论内容用于计算评论长度。at 符号不算作长度。只计算评论文本。 ref: https://github.com/suhanyujie/hello_parser_of_js

func NewCommentCutter

func NewCommentCutter(comment string) *CutCommentObj

func (*CutCommentObj) CutComment

func (obj *CutCommentObj) CutComment(limit int) string

func (*CutCommentObj) Peek

func (obj *CutCommentObj) Peek(n int) string

Peek 查看接下来的 n 个字符,但不消耗

func (*CutCommentObj) Read

func (obj *CutCommentObj) Read(n int) string

Read 读取并消耗 n 个字符

func (*CutCommentObj) ReadAttachmentText

func (obj *CutCommentObj) ReadAttachmentText() (consumeStr string, isAttach bool)

ReadAttachmentText 读取并消耗 `[附件]` 文本

func (*CutCommentObj) ReadCommentText

func (obj *CutCommentObj) ReadCommentText() string

func (*CutCommentObj) ReadOneAtExp

func (obj *CutCommentObj) ReadOneAtExp() (consumeStr string, isAtText bool)

ReadOneAtExp 读取一个 at 标签字符串 <at id=ou_3ab7fe596cf91692218f744558ae157f></at>

func (*CutCommentObj) SkipWhitespace

func (obj *CutCommentObj) SkipWhitespace()

Jump to

Keyboard shortcuts

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