cystring

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PadStart

func PadStart(s string, length int, pad string) string

func RemoveSqlComments

func RemoveSqlComments(line string, inMultiLineComment bool) (processedLine string, stillInComment bool)

func ReplaceSqlStringContent

func ReplaceSqlStringContent(line string, expectedEnd string, vPlaceholder ...string) (processedLine string, nextExpectedEnd string)

ReplaceSqlStringContent 替换 SQL 字符串内容为占位符。

参数:

  • line: SQL 语句行
  • expectedEnd: 期望的字符串结束符
  • vPlaceholder: 可选的占位符字符串(默认 "___STR___")

返回值:

  • string: 处理后的行
  • string: 下一个期望的结束符

用法:

line := "SELECT * FROM users WHERE name = 'John'"
processed, nextEnd := ReplaceSqlStringContent(line, "")
// processed 中字符串内容被替换为占位符

局限:

  • 用于 SQL 解析时的字符串处理
  • 复杂的 SQL 语句可能无法正确处理

Types

type DelimiterInfo

type DelimiterInfo struct {
	S string // 分隔符的内容
	P int    // 分隔符在原字符串中的起始位置(索引)
}

DelimiterInfo 用于存储找到的分隔符信息

func FindDelimiters

func FindDelimiters(str, sep string) []DelimiterInfo

FindDelimiters 查找字符串中所有连续的分隔符。

参数:

  • str: 需要查找的字符串
  • sep: 分隔符字符串

返回值:

  • []DelimiterInfo: 包含分隔符信息的切片

用法:

delimiters := FindDelimiters("hello,,,world,,test", ",")
// delimiters[0] = DelimiterInfo{S: ",,,", P: 5}
// delimiters[1] = DelimiterInfo{S: ",,", P: 16}

特点:

  • 合并连续的分隔符
  • 返回分隔符的位置

局限:

  • 分隔符为空时返回空切片
  • 不支持正则表达式分隔符

Jump to

Keyboard shortcuts

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