]> Sergey Matveev's repositories - path-extractor.git/blob - extractor.go
Update path to demo gif
[path-extractor.git] / extractor.go
1 package main
2
3 import "regexp"
4
5
6 func pathExtractor(input string) [][][]byte {
7     surroundRegex := "[^][ \\t:'\"]"
8     r := regexp.MustCompile("("+surroundRegex+"*[\\./]"+surroundRegex+"*)")
9     temp := [][][]byte{}
10     temp = r.FindAllSubmatch([]byte(input),-1)
11     return temp
12 }
13
14 func getAllMatches(input string) []string {
15     matches := [][][]byte{}
16     result := []string{}
17     s := string("")
18     matches = pathExtractor(input)
19     for _,match := range matches {
20         s = string(match[1])
21         if isDate(s) || isVersion(s) || isGitRange(s) || isGitInstruction(s) || containsInvalidString(s) || len(s)<=2 {
22             continue
23         }
24         if isGitPath(s) {
25             s = replaceGitPath(s)
26         }
27         result = append(result,s)
28     }
29     return result
30 }