summaryrefslogtreecommitdiffstats
path: root/src/pattern.go
diff options
context:
space:
mode:
authorJunegunn Choi <junegunn.c@gmail.com>2015-06-08 23:16:31 +0900
committerJunegunn Choi <junegunn.c@gmail.com>2015-06-08 23:17:24 +0900
commit0be4cead2011440b0cc40f404953f1903673adc3 (patch)
tree3295d36cace54a5ead0ddb284815b7eb9592da81 /src/pattern.go
parent443a80f254c8a21c17de910533bb11fcd253eb02 (diff)
Allow ^EqualMatch$
Diffstat (limited to 'src/pattern.go')
-rw-r--r--src/pattern.go11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/pattern.go b/src/pattern.go
index 64e0c6e1..ffdf6d8b 100644
--- a/src/pattern.go
+++ b/src/pattern.go
@@ -24,6 +24,7 @@ const (
termExact
termPrefix
termSuffix
+ termEqual
)
type term struct {
@@ -116,6 +117,7 @@ func BuildPattern(mode Mode, caseMode Case,
procFun: make(map[termType]func(bool, *[]rune, []rune) (int, int))}
ptr.procFun[termFuzzy] = algo.FuzzyMatch
+ ptr.procFun[termEqual] = algo.EqualMatch
ptr.procFun[termExact] = algo.ExactMatchNaive
ptr.procFun[termPrefix] = algo.PrefixMatch
ptr.procFun[termSuffix] = algo.SuffixMatch
@@ -151,8 +153,13 @@ func parseTerms(mode Mode, caseMode Case, str string) []term {
text = text[1:]
}
} else if strings.HasPrefix(text, "^") {
- typ = termPrefix
- text = text[1:]
+ if strings.HasSuffix(text, "$") {
+ typ = termEqual
+ text = text[1 : len(text)-1]
+ } else {
+ typ = termPrefix
+ text = text[1:]
+ }
} else if strings.HasSuffix(text, "$") {
typ = termSuffix
text = text[:len(text)-1]