pcre

package module
v0.0.0-...-b4f1834 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2022 License: MIT Imports: 7 Imported by: 1

README

GO PCRE

go-pcre is a CGO-free wrapper around PCRE2 regular expression engine.

I created this repo for a specific use, which requires only the compile methods. Feel free to extend pcre.go to include more methods.

Important Note

All the credits go to Arsen6331 for starting this project. This repo is a based on his repo.

Supported Arch and OS:
  • linux/amd64
  • linux/386
  • darwin/amd64
  • darwin/arm64

Documentation

Overview

Package pcre is a library that provides pcre2 regular expressions in pure Go, allowing for features such as cross-compiling.

The lib directory contains source code automatically translated from pcre2's C source code for each supported architecture and/or OS. This package wraps the automatically-translated source to provide a safe interface as close to Go's regexp library as possible.

Index

Constants

View Source
const (
	Anchored          = CompileOption(lib.DPCRE2_ANCHORED)
	AllowEmptyClass   = CompileOption(lib.DPCRE2_ALLOW_EMPTY_CLASS)
	AltBsux           = CompileOption(lib.DPCRE2_ALT_BSUX)
	AltCircumflex     = CompileOption(lib.DPCRE2_ALT_CIRCUMFLEX)
	AltVerbnames      = CompileOption(lib.DPCRE2_ALT_VERBNAMES)
	AutoCallout       = CompileOption(lib.DPCRE2_AUTO_CALLOUT)
	Caseless          = CompileOption(lib.DPCRE2_CASELESS)
	DollarEndOnly     = CompileOption(lib.DPCRE2_DOLLAR_ENDONLY)
	DotAll            = CompileOption(lib.DPCRE2_DOTALL)
	DupNames          = CompileOption(lib.DPCRE2_DUPNAMES)
	EndAnchored       = CompileOption(lib.DPCRE2_ENDANCHORED)
	Extended          = CompileOption(lib.DPCRE2_EXTENDED)
	FirstLine         = CompileOption(lib.DPCRE2_FIRSTLINE)
	Literal           = CompileOption(lib.DPCRE2_LITERAL)
	MatchInvalidUTF   = CompileOption(lib.DPCRE2_MATCH_INVALID_UTF)
	MatchUnsetBackref = CompileOption(lib.DPCRE2_MATCH_UNSET_BACKREF)
	Multiline         = CompileOption(lib.DPCRE2_MULTILINE)
	NeverBackslashC   = CompileOption(lib.DPCRE2_NEVER_BACKSLASH_C)
	NeverUCP          = CompileOption(lib.DPCRE2_NEVER_UCP)
	NeverUTF          = CompileOption(lib.DPCRE2_NEVER_UTF)
	NoAutoCapture     = CompileOption(lib.DPCRE2_NO_AUTO_CAPTURE)
	NoAutoPossess     = CompileOption(lib.DPCRE2_NO_AUTO_POSSESS)
	NoDotStarAnchor   = CompileOption(lib.DPCRE2_NO_DOTSTAR_ANCHOR)
	NoStartOptimize   = CompileOption(lib.DPCRE2_NO_START_OPTIMIZE)
	NoUTFCheck        = CompileOption(lib.DPCRE2_NO_UTF_CHECK)
	UCP               = CompileOption(lib.DPCRE2_UCP)
	Ungreedy          = CompileOption(lib.DPCRE2_UNGREEDY)
	UseOffsetLimit    = CompileOption(lib.DPCRE2_USE_OFFSET_LIMIT)
	UTF               = CompileOption(lib.DPCRE2_UTF)
)

Compile option bits

Variables

This section is empty.

Functions

func Version

func Version() string

Version returns the version of pcre2 embedded in this library.

Types

type CompileOption

type CompileOption uint32

type PcreError

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

PcreError represents errors returned by underlying pcre2 functions.

func (*PcreError) Error

func (pe *PcreError) Error() string

Error returns the string within the error, prepending the offset if it exists.

type Regexp

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

Regexp represents a pcre2 regular expression

func Compile

func Compile(pattern string) (*Regexp, error)

Compile runs CompileOpts with no options.

Close() should be called on the returned expression once it is no longer needed.

func CompileOpts

func CompileOpts(pattern string, options CompileOption) (*Regexp, error)

CompileOpts compiles the provided pattern using the given options.

Close() should be called on the returned expression once it is no longer needed.

func MustCompile

func MustCompile(pattern string) *Regexp

MustCompile compiles the given pattern and panics if there was an error

Close() should be called on the returned expression once it is no longer needed.

func MustCompileOpts

func MustCompileOpts(pattern string, options CompileOption) *Regexp

MustCompileOpts compiles the given pattern with the given options and panics if there was an error.

Close() should be called on the returned expression once it is no longer needed.

func (*Regexp) Close

func (r *Regexp) Close() error

Close frees resources used by the regular expression.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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