https://github.com/shellyln/go-sql-like-expr
Convert SQL Like patterns to Go regular expressions.
https://github.com/shellyln/go-sql-like-expr
go golang golang-library library regex regex-pattern regexp sql
Last synced: about 1 year ago
JSON representation
Convert SQL Like patterns to Go regular expressions.
- Host: GitHub
- URL: https://github.com/shellyln/go-sql-like-expr
- Owner: shellyln
- License: mit
- Created: 2023-01-31T22:47:41.000Z (about 3 years ago)
- Default Branch: master
- Last Pushed: 2023-01-31T22:54:53.000Z (about 3 years ago)
- Last Synced: 2025-01-29T09:44:57.989Z (about 1 year ago)
- Topics: go, golang, golang-library, library, regex, regex-pattern, regexp, sql
- Language: Go
- Homepage:
- Size: 3.91 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: Changelog.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Go SQL Like expression
Convert SQL Like patterns to Go regular expressions.
[](https://github.com/shellyln/go-sql-like-expr/actions/workflows/test.yml)
[](https://github.com/shellyln/go-sql-like-expr/releases)
[](https://github.com/shellyln/go-sql-like-expr)
## 🚀 Usage
```go
package main
import (
"fmt"
"regexp"
"github.com/shellyln/go-sql-like-expr/likeexpr"
)
func main() {
// Parameters:
// Like pattern, Escape character, Escaping the escape character itself
pat := likeexpr.ToRegexp("fo%ba_", '\\', false)
re, err := regexp.Compile(pat)
if err != nil {
fmt.Printf("Compile: error = %v\n", err)
return
}
matched := re.MatchString("fooobar")
fmt.Printf("Compile: matched = %v\n", matched)
}
```
## ⚖️ License
MIT
Copyright (c) 2023 Shellyl_N and Authors.