Files
sqimple/column.go
T

30 lines
534 B
Go
Raw Normal View History

2026-07-07 20:29:58 +01:00
package sqimple
2026-07-07 17:25:02 +01:00
import (
"regexp"
)
2026-07-10 17:07:54 +01:00
var columnRegexp = regexp.MustCompile("^(.+)( as ([A-Za-z0-9_]+))?$")
2026-07-07 17:25:02 +01:00
type Column string
func (c Column) IsValid() bool {
return columnRegexp.MatchString(string(c))
}
func (c Column) Parse() (string, string, bool) {
if columnRegexp.MatchString(string(c)) {
result := columnRegexp.FindAllStringSubmatch(string(c), -1)
for _, r := range result {
column, as := r[1], r[3]
return column, as, true
}
}
return "", "", false
}
func (c Column) String() string {
return string(c)
}