initial commit
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
package simql
|
||||
|
||||
import (
|
||||
"regexp"
|
||||
)
|
||||
|
||||
var columnRegexp = regexp.MustCompile("^([^ ]+)( as ([^ ]+))?$")
|
||||
|
||||
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)
|
||||
}
|
||||
Reference in New Issue
Block a user