Documentation
¶
Overview ¶
Package bmatch is a string matching library with boolean expressions.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Explain ¶
Explain parses a bmatch expression and returns, if successful, a string representation of its syntax tree.
Example ¶
package main
import (
"fmt"
"log"
"github.com/cvilsmeier/bmatch"
)
func main() {
plan, err := bmatch.Explain("/foo/ OR /bar/ AND NOT /bill/")
if err != nil {
log.Fatal(err)
}
fmt.Println(plan)
}
Output: OR[/foo/,AND[/bar/,NOT[/bill/]]]
Types ¶
type Matcher ¶
A Matcher matches strings.
func Compile ¶
Compile parses a bmatch expression and returns, if successful, a Matcher object that can be used to match strings.
Example ¶
package main
import (
"fmt"
"log"
"github.com/cvilsmeier/bmatch"
)
func main() {
matcher, err := bmatch.Compile("/foo/ AND NOT /bar/")
if err != nil {
log.Fatal(err)
}
fmt.Println(matcher.Match("foo")) // true
fmt.Println(matcher.Match("bar")) // false
fmt.Println(matcher.Match("foobar")) // false
fmt.Println(matcher.Match("barfoo")) // false
fmt.Println(matcher.Match("foother")) // true
}
Output: true false false false true
func MustCompile ¶
MustCompile is like Compile but panics on error.
Click to show internal directories.
Click to hide internal directories.