Skip to content

Commit

Permalink
fix matcher
Browse files Browse the repository at this point in the history
  • Loading branch information
minoritea committed Aug 20, 2021
1 parent 9708a1c commit 71260a8
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,16 @@ func run() error {
return nil
}

var matcher = regexp.MustCompile(`^(FROM|from) \w+ (AS|as) (\w+)$`)
var matcher = regexp.MustCompile(`^(FROM|from) ([\w:.-]+) (AS|as) (\w+)$`)

func parse(r io.Reader) ([]string, error) {
scanner := bufio.NewScanner(r)
var result []string
for scanner.Scan() {
line := scanner.Bytes()
m := matcher.FindAllSubmatch(line, -1)
if len(m) > 0 && len(m[0]) > 3 {
result = append(result, string(m[0][3]))
if len(m) > 0 && len(m[0]) > 4 {
result = append(result, string(m[0][4]))
}
}
return result, scanner.Err()
Expand Down

0 comments on commit 71260a8

Please sign in to comment.