matcher

package module
v0.0.0-...-9985a9d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 19, 2018 License: Apache-2.0 Imports: 1 Imported by: 5

README

Go PCRE Matcher

GoDoc

Provides a simple and compatible matcher interface around Go PCRE.

Contact: developer@tenta.io

Installation

  1. go get github.com/tenta-browser/go-pcre-matcher

License

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

For any questions, please contact developer@tenta.io

Contributing

We welcome contributions, feedback and plain old complaining. Feel free to open an issue or shoot us a message to developer@tenta.io. If you'd like to contribute, please open a pull request and send us an email to sign a contributor agreement.

About Tenta

This regex library is brought to you by Team Tenta. Tenta is your private, encrypted browser that protects your data instead of selling. We're building a next-generation browser that combines all the privacy tools you need, including built-in OpenVPN. Everything is encrypted by default. That means your bookmarks, saved tabs, web history, web traffic, downloaded files, IP address and DNS. A truly incognito browser that's fast and easy.

Documentation

Overview

Package matcher provides a simple and compatible matcher interface around [Go PCRE](https://github.com/gijsbers/go-pcre).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ReTest

func ReTest() string

ReTest runs a quick match, it should be 23,7. What else?

Types

type Engine

type Engine interface {
	Compile(pattern string, flags int) (Regexp, error)
	Quote(s string) string

	FlagDotAll() int
	FlagExtended() int
	FlagUnicode() int
	FlagCaseInsensitive() int
	FlagMultiline() int
}

Engine represents a regexp engine

var ReEngine Engine

ReEngine contains the regexp engine which should be used for all matching; For local dev runs init this with 'matcherpcre.NewEngine()'. For production uses init it from Java with its implementation.

type Match

type Match interface {
	// Groups returns the number of capturing groups in the pattern
	Groups() int
	// GroupByIdx returns the value of a group by index
	// Important: GroupByIdx(0) returns the full match, the first group has index 1
	GroupByIdx(idx int) string
	// GroupPresentByIdx returns whether the specified group is present in the succesful match
	GroupPresentByIdx(idx int) bool
	// GroupByName returns the value of a group by name
	GroupByName(name string) string
	// GroupPresentByName returns whether the specified group is present in the succesful match
	GroupPresentByName(name string) bool
	// Next tries to find a next match, returns true if it succeeds;
	// after calling this method all info about the previous match gets lost
	Next() bool
}

Match represents the result of a successful match

type Regexp

type Regexp interface {
	// Search returns the leftmost successful match or nil if the pattern failed to match
	Search(subject string) Match
	// Replace replaces every occurrence of the pattern with repl
	// (group references in repl are in Perl/Java style: $0, $1, $2, ..)
	Replace(subject, repl string) string
	// ReplaceFunc replaces every occurrence of the pattern with
	// replacements produced by invoking the replacer on every match
	ReplaceFunc(subject string, replacer Replacer) string
}

Regexp represents compiled regular expression

type Replacer

type Replacer interface {
	Replacement(match Match) string
}

Replacer produces replacements for matches

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL