7 type MatchOptions struct {
11 func pathExtractor(input string) [][]int {
12 surroundRegex := "[@~\\-_a-zA-Z/.0-9]*"
13 r := regexp.MustCompile("(" + surroundRegex + "[\\./]" + surroundRegex + ")")
14 return r.FindAllSubmatchIndex([]byte(input), -1)
17 func stripParens(input string) string {
18 r := regexp.MustCompile("^\\((.*)\\)$")
20 temp = r.FindSubmatch([]byte(input))
24 return string(temp[1])
27 func postProcess(input string) string {
28 input = stripParens(input)
32 func GetAllMatches(input string, options MatchOptions) []string {
34 candidatePath := string("")
35 indexes := pathExtractor(input)
36 for _, index := range indexes {
37 candidatePath = input[index[0]:index[1]]
38 if len(input) >= len(candidatePath+"(") && strings.Index(input, candidatePath+"(") != -1 {
42 if isEmail(candidatePath) || isDate(candidatePath) || isVersion(candidatePath) || isGitRange(candidatePath) || isGitInstruction(candidatePath) || endsWithInvalidString(candidatePath) || containsInvalidString(candidatePath) || len(candidatePath) <= 2 {
45 if isGitPath(candidatePath) {
46 candidatePath = replaceGitPath(candidatePath)
48 candidatePath = postProcess(candidatePath)
51 if options.format == "ackmate" {
52 candidatePath = fmt.Sprint(candidatePath, ":", lineNumber, ":", columnNumber)
54 result = append(result, candidatePath)