icuregex

package
v0.19.5 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const BreakIteration = false

Variables

This section is empty.

Functions

This section is empty.

Types

type Code

type Code int32

type CompileError

type CompileError struct {
	Code    CompileErrorCode
	Line    int
	Offset  int
	Context string
}

func (*CompileError) Error

func (e *CompileError) Error() string

type CompileErrorCode

type CompileErrorCode int32
const (
	InternalError           CompileErrorCode = iota + 1 /**< An internal error (bug) was detected.              */
	RuleSyntax                                          /**< Syntax error in regexp pattern.                    */
	BadEscapeSequence                                   /**< Unrecognized backslash escape sequence in pattern  */
	PropertySyntax                                      /**< Incorrect Unicode property                         */
	Unimplemented                                       /**< Use of regexp feature that is not yet implemented. */
	MismatchedParen                                     /**< Incorrectly nested parentheses in regexp pattern.  */
	NumberTooBig                                        /**< Decimal number is too large.                       */
	BadInterval                                         /**< Error in {min,max} interval                        */
	MaxLtMin                                            /**< In {min,max}, max is less than min.                */
	InvalidBackRef                                      /**< Back-reference to a non-existent capture group.    */
	InvalidFlag                                         /**< Invalid value for match mode flags.                */
	LookBehindLimit                                     /**< Look-Behind pattern matches must have a bounded maximum length.    */
	MissingCloseBracket                                 /**< Missing closing bracket on a bracket expression. */
	InvalidRange                                        /**< In a character range [x-y], x is greater than y.   */
	PatternTooBig                                       /**< Pattern exceeds limits on size or complexity. @stable ICU 55 */
	InvalidCaptureGroupName                             /**< Invalid capture group name. @stable ICU 55 */
)

type MatchError

type MatchError struct {
	Code     MatchErrorCode
	Pattern  string
	Position int
	Input    []rune
}

func (*MatchError) Error

func (e *MatchError) Error() string

type MatchErrorCode

type MatchErrorCode int32
const (
	StackOverflow      MatchErrorCode = iota /**< Regular expression backtrack stack overflow.       */
	TimeOut                                  /**< Maximum allowed match time exceeded                */
	InternalMatchError                       /**< Internal error (bug) was detected.                 */
)

type Matcher

type Matcher struct {
	// contains filtered or unexported fields
}

func NewMatcher

func NewMatcher(pat *Pattern) *Matcher

func (*Matcher) Dumper

func (m *Matcher) Dumper(out io.Writer)

func (*Matcher) End

func (m *Matcher) End() int

func (*Matcher) EndForGroup

func (m *Matcher) EndForGroup(group int) int

func (*Matcher) Find

func (m *Matcher) Find() (bool, error)

func (*Matcher) Group

func (m *Matcher) Group(i int) (string, bool)

func (*Matcher) GroupCount

func (m *Matcher) GroupCount() int

func (*Matcher) HitEnd

func (m *Matcher) HitEnd() bool

func (*Matcher) LookingAt

func (m *Matcher) LookingAt() (bool, error)

func (*Matcher) MatchAt

func (m *Matcher) MatchAt(startIdx int, toEnd bool) error

func (*Matcher) Matches

func (m *Matcher) Matches() (bool, error)

func (*Matcher) RequireEnd

func (m *Matcher) RequireEnd() bool

func (*Matcher) Reset

func (m *Matcher) Reset(input []rune)

func (*Matcher) ResetString

func (m *Matcher) ResetString(input string)

func (*Matcher) Start

func (m *Matcher) Start() int

func (*Matcher) StartForGroup

func (m *Matcher) StartForGroup(group int) int

type Pattern

type Pattern struct {
	// contains filtered or unexported fields
}

func Compile

func Compile(in []rune, flags RegexpFlag) (*Pattern, error)

func CompileString

func CompileString(in string, flags RegexpFlag) (*Pattern, error)

func NewPattern

func NewPattern(flags RegexpFlag) *Pattern

func (*Pattern) Dump

func (pat *Pattern) Dump(w io.Writer)

func (*Pattern) Match

func (p *Pattern) Match(input string) *Matcher

type RegexpFlag

type RegexpFlag int32
const (
	/**  Enable case insensitive matching.  @stable ICU 2.4 */
	CaseInsensitive RegexpFlag = 2

	/**  Allow white space and comments within patterns  @stable ICU 2.4 */
	Comments RegexpFlag = 4

	/**  If set, '.' matches line terminators,  otherwise '.' matching stops at line end.
	 *  @stable ICU 2.4 */
	DotAll RegexpFlag = 32

	/**  If set, treat the entire pattern as a literal string.
	 *  Metacharacters or escape sequences in the input sequence will be given
	 *  no special meaning.
	 *
	 *  The flag UREGEX_CASE_INSENSITIVE retains its impact
	 *  on matching when used in conjunction with this flag.
	 *  The other flags become superfluous.
	 *
	 * @stable ICU 4.0
	 */
	Literal RegexpFlag = 16

	/**   Control behavior of "$" and "^"
	 *    If set, recognize line terminators within string,
	 *    otherwise, match only at start and end of input string.
	 *   @stable ICU 2.4 */
	Multiline RegexpFlag = 8

	/**   Unix-only line endings.
	 *   When this mode is enabled, only \\u000a is recognized as a line ending
	 *    in the behavior of ., ^, and $.
	 *   @stable ICU 4.0
	 */
	UnixLines RegexpFlag = 1

	/**  Unicode word boundaries.
	 *     If set, \b uses the Unicode TR 29 definition of word boundaries.
	 *     Warning: Unicode word boundaries are quite different from
	 *     traditional regular expression word boundaries.  See
	 *     http://unicode.org/reports/tr29/#Word_Boundaries
	 *     @stable ICU 2.8
	 */
	UWord RegexpFlag = 256

	/**  Error on Unrecognized backslash escapes.
	 *     If set, fail with an error on patterns that contain
	 *     backslash-escaped ASCII letters without a known special
	 *     meaning.  If this flag is not set, these
	 *     escaped letters represent themselves.
	 *     @stable ICU 4.0
	 */
	ErrorOnUnknownEscapes RegexpFlag = 512
)

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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