From: Edgar HIPP Date: Sun, 30 Aug 2015 15:07:09 +0000 (+0200) Subject: Shouldn't match + nor ^ X-Git-Url: http://www.git.stargrave.org/?p=path-extractor.git;a=commitdiff_plain;h=4e2aeee3327fea7dacf7d3d51365dc77b6ce090e Shouldn't match + nor ^ --- diff --git a/extractor.go b/extractor.go index 8e80d2c..f64fe5f 100644 --- a/extractor.go +++ b/extractor.go @@ -9,7 +9,7 @@ type MatchOptions struct { } func pathExtractor(input string) [][][]byte { - surroundRegex := "[^]()!#[ \\t:'\"\\\\]*" + surroundRegex := "[^]\\^\\+()!#[ \\t:'\"\\\\]*" r := regexp.MustCompile("(" + surroundRegex + "[\\./]" + surroundRegex + ")") temp := [][][]byte{} temp = r.FindAllSubmatch([]byte(input), -1) diff --git a/pe_test.go b/pe_test.go index a2c563a..28f87f7 100644 --- a/pe_test.go +++ b/pe_test.go @@ -13,6 +13,16 @@ func TestEverything(t *testing.T) { t.Errorf("Matches sentence", output) } + output = GetAllMatches("s/+//", MatchOptions{}) + if len(output) != 0 { + t.Errorf("Doesn't match substitute", output) + } + + output = GetAllMatches("s/^//", MatchOptions{}) + if len(output) != 0 { + t.Errorf("Doesn't match substitute", output) + } + output = GetAllMatches("/usr/bin/env\\", MatchOptions{}) if len(output) != 1 { t.Errorf("Doesn't match escaped", output)