1234567891011121314151617181920212223242526272829303132333435363738 |
- package utils
- import (
- "fmt"
- "regexp"
- "strings"
- )
- // 切分;分号前后,分为俩个字符串
- func SplitSemicolon(sql string) (string, string) {
- // 找到第一个分号的位置
- semicolonIndex := strings.Index(sql, ";")
- if semicolonIndex != -1 {
- // 切分分号前的语句
- front := sql[:semicolonIndex+1]
- rear := sql[semicolonIndex+1:]
- return front, rear
- } else {
- fmt.Println("未找到分号。")
- return "", ""
- }
- }
- // 检查字符串中是否包含指定的关键字
- func ContainsKeyword(input string, keyword string) bool {
- return strings.Contains(input, keyword)
- }
- func IsInsertBlob(input string) int {
- re := regexp.MustCompile(`values\(([^)]*)\)`)
- match := re.FindStringSubmatch(input)
- if len(match) > 1 {
- return strings.Count(match[1], "?")
- }
- return 0
- }
|