package syntax
Import Path
regexp/syntax (on golang.org and go.dev)
Dependency Relation
imports 5 packages, and imported by one package
Involved Source Files
compile.go
d-> doc.go
op_string.go
parse.go
perl_groups.go
prog.go
regexp.go
simplify.go
Exported Type Names
type EmptyOp uint8
An EmptyOp specifies a kind or mixture of zero-width assertions.
func EmptyOpContext(r1, r2 rune) EmptyOp
func (*Prog).StartCond() EmptyOp
const EmptyBeginLine
const EmptyBeginText
const EmptyEndLine
const EmptyEndText
const EmptyNoWordBoundary
const EmptyWordBoundary
type Error (struct)
An Error describes a failure to parse a regular expression
and gives the offending expression.
Code ErrorCode
Expr string
(*T) Error() string
*T : error
type ErrorCode string
An ErrorCode describes a failure to parse a regular expression.
(T) String() string
T : fmt.Stringer
const ErrInternalError
const ErrInvalidCharClass
const ErrInvalidCharRange
const ErrInvalidEscape
const ErrInvalidNamedCapture
const ErrInvalidPerlOp
const ErrInvalidRepeatOp
const ErrInvalidRepeatSize
const ErrInvalidUTF8
const ErrMissingBracket
const ErrMissingParen
const ErrMissingRepeatArgument
const ErrTrailingBackslash
const ErrUnexpectedParen
type Flags uint16
Flags control the behavior of the parser and record information about regexp context.
func Parse(s string, flags Flags) (*Regexp, error)
const ClassNL
const DotNL
const FoldCase
const Literal
const MatchNL
const NonGreedy
const OneLine
const Perl
const PerlX
const POSIX
const Simple
const UnicodeGroups
const WasDollar
type Inst (struct)
An Inst is a single instruction in a regular expression program.
Arg uint32
Op InstOp
Out uint32
Rune []rune
(*T) MatchEmptyWidth(before rune, after rune) bool
(*T) MatchRune(r rune) bool
(*T) MatchRunePos(r rune) int
(*T) String() string
*T : fmt.Stringer
type InstOp uint8
An InstOp is an instruction opcode.
(T) String() string
T : fmt.Stringer
const InstAlt
const InstAltMatch
const InstCapture
const InstEmptyWidth
const InstFail
const InstMatch
const InstNop
const InstRune
const InstRune1
const InstRuneAny
const InstRuneAnyNotNL
type Op uint8
An Op is a single regular expression operator.
(T) String() string
T : fmt.Stringer
const OpAlternate
const OpAnyChar
const OpAnyCharNotNL
const OpBeginLine
const OpBeginText
const OpCapture
const OpCharClass
const OpConcat
const OpEmptyMatch
const OpEndLine
const OpEndText
const OpLiteral
const OpNoMatch
const OpNoWordBoundary
const OpPlus
const OpQuest
const OpRepeat
const OpStar
const OpWordBoundary
type Prog (struct)
A Prog is a compiled regular expression program.
Inst []Inst
NumCap int
Start int
(*T) Prefix() (prefix string, complete bool)
(*T) StartCond() EmptyOp
(*T) String() string
*T : fmt.Stringer
func Compile(re *Regexp) (*Prog, error)
type Regexp (struct)
A Regexp is a node in a regular expression syntax tree.
Cap int
Flags Flags
Max int
Min int
Name string
Op Op
Rune []rune
Rune0 [2]rune
Sub []*Regexp
Sub0 [1]*Regexp
(*T) CapNames() []string
(*T) Equal(y *Regexp) bool
(*T) MaxCap() int
(*T) Simplify() *Regexp
(*T) String() string
*T : fmt.Stringer
func Parse(s string, flags Flags) (*Regexp, error)
func (*Regexp).Simplify() *Regexp
func Compile(re *Regexp) (*Prog, error)
func (*Regexp).Equal(y *Regexp) bool
Exported Values
func Compile(re *Regexp) (*Prog, error)
Compile compiles the regexp into a program to be executed.
The regexp should have been simplified already (returned from re.Simplify).
const EmptyBeginLine EmptyOp = 1
const EmptyBeginText EmptyOp = 4
const EmptyEndLine EmptyOp = 2
const EmptyEndText EmptyOp = 8
const EmptyNoWordBoundary EmptyOp = 32
func EmptyOpContext(r1, r2 rune) EmptyOp
EmptyOpContext returns the zero-width assertions
satisfied at the position between the runes r1 and r2.
Passing r1 == -1 indicates that the position is
at the beginning of the text.
Passing r2 == -1 indicates that the position is
at the end of the text.
const EmptyWordBoundary EmptyOp = 16
const ErrInternalError ErrorCode = "regexp/syntax: internal error"
Unexpected error
const ErrInvalidCharClass ErrorCode = "invalid character class"
Parse errors
const ErrInvalidCharRange ErrorCode = "invalid character class range"
const ErrInvalidEscape ErrorCode = "invalid escape sequence"
const ErrInvalidNamedCapture ErrorCode = "invalid named capture"
const ErrInvalidPerlOp ErrorCode = "invalid or unsupported Perl syntax"
const ErrInvalidRepeatOp ErrorCode = "invalid nested repetition operator"
const ErrInvalidRepeatSize ErrorCode = "invalid repeat count"
const ErrInvalidUTF8 ErrorCode = "invalid UTF-8"
const ErrMissingBracket ErrorCode = "missing closing ]"
const ErrMissingParen ErrorCode = "missing closing )"
const ErrMissingRepeatArgument ErrorCode = "missing argument to repetition operator"
const ErrTrailingBackslash ErrorCode = "trailing backslash at end of expression"
const ErrUnexpectedParen ErrorCode = "unexpected )"
const InstAltMatch InstOp = 1
const InstCapture InstOp = 2
const InstEmptyWidth InstOp = 3
const InstRuneAny InstOp = 9
const InstRuneAnyNotNL InstOp = 10
func IsWordChar(r rune) bool
IsWordChar reports whether r is consider a ``word character''
during the evaluation of the \b and \B zero-width assertions.
These assertions are ASCII-only: the word characters are [A-Za-z0-9_].
const OpAlternate Op = 19 // matches alternation of Subs
const OpAnyCharNotNL Op = 5 // matches any character except newline
const OpBeginLine Op = 7 // matches empty string at beginning of line
const OpBeginText Op = 9 // matches empty string at beginning of text
const OpCharClass Op = 4 // matches Runes interpreted as range pair list
const OpEmptyMatch Op = 2 // matches empty string
const OpNoWordBoundary Op = 12 // matches word non-boundary `\B`
const OpWordBoundary Op = 11 // matches word boundary `\b`
func Parse(s string, flags Flags) (*Regexp, error)
Parse parses a regular expression string s, controlled by the specified
Flags, and returns a regular expression parse tree. The syntax is
described in the top-level comment.
const UnicodeGroups Flags = 128 // allow \p{Han}, \P{Han} for Unicode group and negation
![]() |
The pages are generated with Golds v0.1.6. (GOOS=darwin GOARCH=amd64) Golds is a Go 101 project and developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds. |