Documentation
¶
Overview ¶
Package netregex runs .NET-flavour regular expressions with .NET's match semantics, as dlclark/regexp2 defines them, in polynomial time.
Go's regexp/syntax compiles each pattern and a Pike VM runs it with .NET's assertions: Unicode \b, \B, \w, \d and \s, and $ also before a final \n. Each lookaround is a position predicate over the whole input, memoized per call. A lookbehind costs one pass over the input; a lookahead one anchored run per position it is asked at. For an n-byte input and a pattern whose programs hold m instructions in all, a call is O(n²·m); release names are clamped to 512 bytes. Backreferences, atomic groups, conditionals, inline options other than (?i:) and (?-i:), and a named group in a loop that can match empty are refused at Compile.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsWordChar ¶
IsWordChar reports whether r is a .NET word character: what \w matches and \b and \B test on each side.
Types ¶
type Regexp ¶
type Regexp struct {
// contains filtered or unexported fields
}
Regexp is a compiled pattern; it is safe for concurrent use.
func Compile ¶
Compile reads a .NET pattern; the error is an *UnsupportedError for a construct the executor does not run.
func (*Regexp) Find ¶
Find is .NET's Match(s, from): the leftmost match starting at or after byte from, the text before from still in view, as byte offsets in the SubexpNames order (-1 for a group that took no part); nil when none.
func (*Regexp) FindAll ¶
FindAll is .NET's Matches: each search starts where the last match ended, one rune further after an empty one.
func (*Regexp) MatchString ¶
MatchString is .NET's IsMatch.
func (*Regexp) SubexpIndex ¶
SubexpIndex returns the index of the named group, or -1.
func (*Regexp) SubexpNames ¶
SubexpNames returns each group's name by its index in a match: index 0 is the whole match, and a name used twice in the pattern is one group.
type UnsupportedError ¶
type UnsupportedError struct{ Construct string }
UnsupportedError names a .NET construct the executor does not run.
func (*UnsupportedError) Error ¶
func (e *UnsupportedError) Error() string