pm

package
v1.5.12 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package pm provides Lua pattern matching functions for Go.

Index

Constants

View Source
const MaxBacktracks = 100000

MaxBacktracks limits backtracking to prevent ReDoS attacks.

Variables

This section is empty.

Functions

This section is empty.

Types

type Error

type Error struct {
	Pos     int
	Message string
}

Error represents a pattern matching error.

func (*Error) Error

func (e *Error) Error() string

func (*Error) String

func (e *Error) String() string

type MatchData

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

MatchData holds captured positions from a match. Layout: bit 0 indicates position capture, bits 1+ hold the position value.

func Find

func Find(pattern string, src []byte, offset, limit int) ([]*MatchData, error)

Find searches for pattern matches in src starting at offset. Returns up to limit matches (-1 for unlimited).

func (*MatchData) Capture

func (md *MatchData) Capture(idx int) int

Capture returns the captured position at idx.

func (*MatchData) CaptureLength

func (md *MatchData) CaptureLength() int

CaptureLength returns the number of capture slots.

func (*MatchData) IsPosCapture

func (md *MatchData) IsPosCapture(idx int) bool

IsPosCapture returns true if the capture at idx is a position capture.

Jump to

Keyboard shortcuts

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