syntax

package
v0.0.0-...-f118dbe Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package syntax parses regular expressions into parse trees and compiles parse trees into programs.

Syntax

This package supports following syntax in addition to the golang built-in regexp.

Grouping:

(?>re)         atomic group; non-capturing
(?=re)         lookahead; non-capturing
(?!re)         negative lookahead; non-capturing
(?<=re)        lookbehind; non-capturing
(?<!re)        negative lookbehind; non-capturing
(?{func})      function call; non-capturing
(?#comment)    comment

Repetitions:

x*+            zero or more x, possessive
x++            one or more x, possessive
x?+            zero or one x, possessive
x{n,m}+        n or n+1 or ... or m x, possessive
x{n,}+         n or more x, possessive
x{n}+          exactly n x, possessive

Back reference:

\kN            refer to numbered capturing
\kName         refer to named capturing
\k{N}          refer to numbered capturing
\k{Name}       refer to named capturing

Lookbehind limitations

Lookbehind and negative lookbehind only support expressions that have deterministic matching length.

(?<=abc)        // OK
(?<=.{2,5})     // OK
(?<=foo|barbaz) // OK
(?<=x+)         // NG

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Compile

func Compile(expr string) (re *regexp, extended bool, err error)

Compile parses a regular expression and returns, if successful, a Regexp object that can be used to match against text.

Types

type Context

type Context struct {
	Data    []byte
	Cursor  int
	Matches map[interface{}][]int
}

Context represents a matching context used in a inline function

type FuncMap

type FuncMap map[string]func(ctx Context) interface{}

FuncMap is the type of the map defining the mapping from names to functions.

Jump to

Keyboard shortcuts

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