MCPcopy Index your code
hub / github.com/ByteStorage/FlyDB / convertToRegexp

Function convertToRegexp

structure/types.go:195–205  ·  view source on GitHub ↗
(pattern string)

Source from the content-addressed store, hash-verified

193}
194
195func convertToRegexp(pattern string) string {
196 // 转义正则特殊字符
197 re := regexp.MustCompile(`([\[\]\(\)\{\}\^\$\.\+])`)
198 pattern = re.ReplaceAllString(pattern, `\$1`)
199
200 // 将 * 和 ? 转换为对应的正则表达式
201 pattern = strings.ReplaceAll(pattern, "*", ".*")
202 pattern = strings.ReplaceAll(pattern, "?", ".")
203
204 return "^" + pattern + "$" // 添加 ^ 和 $ 以确保完全匹配
205}

Callers 4

KeysMethod · 0.85
KeysMethod · 0.85
KeysMethod · 0.85
KeysMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected