regexutils

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DestructivelySimplify

func DestructivelySimplify(regex *syntax.Regexp) *syntax.Regexp

DestructivelySimplify simplifies the regex ($regex is not modified), it first calls TurnCapturingGroupsIntoNonCapturing, then syntax.Regexp.DestructivelySimplify, and finally it tries its best to simplify the elements of shape AA* into A+.

func RegexForRange

func RegexForRange(min, max int64, conf ...IntegerRangeRegexConfig) string

RegexForRange returns a regex (not between ^$) that matches all numbers in the range [min, max]. The main logic of the implementation is the same as https://github.com/voronind/range-regex (by Dmitry Voronin, BSD 2-Clause license).

func TurnCapturingGroupsIntoNonCapturing

func TurnCapturingGroupsIntoNonCapturing(regex *syntax.Regexp) *syntax.Regexp

Types

type IntegerRangeRegexConfig

type IntegerRangeRegexConfig struct {
	CapturingGroup bool

	//optional
	NegativeOnlyPrefix, PositiveOnlyPrefix, IntersectedPrefix string
}

Jump to

Keyboard shortcuts

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