Files
2026-07-10 17:07:54 +01:00

30 lines
534 B
Go

package sqimple
import (
"regexp"
)
var columnRegexp = regexp.MustCompile("^(.+)( as ([A-Za-z0-9_]+))?$")
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)
}