regexnew

package
v1.3.55 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2022 License: MIT Imports: 8 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	WhitespaceFinderRegex             = New.Lazy(regconsts.AllWhitespaces)
	HashCommentWithSpaceOptionalRegex = New.Lazy(regconsts.HashCommentWithSpaceOptional)
	WhitespaceOrPipeFinderRegex       = New.Lazy(regconsts.AllWhitespacesOrPipe)
	DollarIdentifierRegex             = New.Lazy(regconsts.EachWordsWithDollarSymbolDefinition)
	PercentIdentifierRegex            = New.Lazy(regconsts.EachWordsWithinPercentSymbolDefinition)
	PrettyNameRegex                   = New.Lazy(regconsts.PrettyName)
	ExactIdFieldMatchingRegex         = New.Lazy(regconsts.ExactIdFieldMatching)
	ExactVersionIdFieldMatchingRegex  = New.Lazy(regconsts.ExactVersionIdFieldMatching)
	UbuntuNameCheckerRegex            = New.Lazy(regconsts.UbuntuNameChecker)
	CentOsNameCheckerRegex            = New.Lazy(regconsts.CentOsNameChecker)
	RedHatNameCheckerRegex            = New.Lazy(regconsts.RedHatNameChecker)
	FirstNumberAnyWhereCheckerRegex   = New.Lazy(regconsts.FirstNumberAnyWhere)
	WindowsVersionNumberCheckerRegex  = FirstNumberAnyWhereCheckerRegex
)
View Source
var (
	New = newCreator{}
)

Functions

func Create added in v1.3.34

func Create(regularExpressionPattern string) (*regexp.Regexp, error)

Create creates regex if not already exist in dictionary.

if any error then doesn't save to map and returns the error

func CreateApplicableLock added in v1.3.34

func CreateApplicableLock(regularExpressionPattern string) (
	regEx *regexp.Regexp,
	err error,
	isApplicable bool,
)

CreateApplicableLock

calls Create with mutex lock and unlock.

func CreateLock added in v1.3.34

func CreateLock(regularExpressionPattern string) (*regexp.Regexp, error)

CreateLock calls Create with mutex lock and unlock.

func CreateLockIf added in v1.3.34

func CreateLockIf(isLock bool, regularExpressionSyntax string) (*regexp.Regexp, error)

CreateLockIf calls Create with mutex lock and unlock if true.

func CreateMust added in v1.3.34

func CreateMust(regularExpressionSyntax string) *regexp.Regexp

CreateMust creates regex if not already exist in dictionary.

if any error then panics

func CreateMustLockIf added in v1.3.34

func CreateMustLockIf(
	isLock bool,
	regularExpressionSyntax string,
) *regexp.Regexp

func IsMatchFailed added in v0.8.0

func IsMatchFailed(regex, comparing string) bool

IsMatchFailed creates new regex using lock and then calls match if doesn't match returns true

func IsMatchLock added in v0.7.6

func IsMatchLock(regex, comparing string) bool

IsMatchLock creates new regex using lock and then calls match if doesn't match or invalid regex then returns false.

func MatchError added in v0.9.5

func MatchError(regex, comparing string) error

MatchError

creates new regex using without lock (use in vars) and then calls match. On condition mismatch returns error or else nil

func MatchErrorLock added in v0.7.6

func MatchErrorLock(regex, comparing string) error

MatchErrorLock

creates new regex using lock and then calls match. On condition mismatch returns error or else nil

func MatchUsingCustomizeErrorFuncLock added in v0.9.5

func MatchUsingCustomizeErrorFuncLock(
	regexPattern, comparing string,
	matchFunc RegexValidationFunc,
	customizeErrFunc CustomizeErr,
) error

MatchUsingCustomizeErrorFuncLock

creates new regex using lock and then calls match. On condition mismatch returns error or else nil

func MatchUsingFuncErrorLock added in v0.9.5

func MatchUsingFuncErrorLock(
	regexPattern, comparing string,
	matchFunc RegexValidationFunc,
) error

MatchUsingFuncErrorLock

creates new regex using lock and then calls match. On condition mismatch returns error or else nil

func NewMustLock

func NewMustLock(regularExpressionSyntax string) *regexp.Regexp

Types

type CustomizeErr added in v0.9.5

type CustomizeErr func(
	regexPattern,
	matchLookingTerm string,
	err error,
	regexp *regexp.Regexp,
) error

type LazyRegex added in v1.3.34

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

LazyRegex

lazy regex for future unwrapping or compiled but only once.

func (*LazyRegex) Compile added in v1.3.34

func (it *LazyRegex) Compile() (regex *regexp.Regexp, err error)

Compile

it is done through the locking mechanism

func (*LazyRegex) CompileMust added in v1.3.34

func (it *LazyRegex) CompileMust() (regex *regexp.Regexp)

func (*LazyRegex) CompiledError added in v1.3.34

func (it *LazyRegex) CompiledError() error

func (*LazyRegex) Error added in v1.3.34

func (it *LazyRegex) Error() error

func (*LazyRegex) FirstMatchLine added in v1.3.34

func (it *LazyRegex) FirstMatchLine(
	content string,
) (firstMatch string, isInvalidMatch bool)

func (*LazyRegex) FullString added in v1.3.34

func (it *LazyRegex) FullString() (detail string)

func (*LazyRegex) HasAnyIssues added in v1.3.34

func (it *LazyRegex) HasAnyIssues() bool

func (*LazyRegex) HasError added in v1.3.34

func (it *LazyRegex) HasError() bool

func (*LazyRegex) IsApplicable added in v1.3.34

func (it *LazyRegex) IsApplicable() bool

IsApplicable

it unwraps the regex and compiles so take memory for once.

func (*LazyRegex) IsCompiled added in v1.3.34

func (it *LazyRegex) IsCompiled() bool

func (*LazyRegex) IsDefined added in v1.3.34

func (it *LazyRegex) IsDefined() bool

func (*LazyRegex) IsFailedMatch added in v1.3.34

func (it *LazyRegex) IsFailedMatch(
	comparing string,
) bool

func (*LazyRegex) IsFailedMatchBytes added in v1.3.34

func (it *LazyRegex) IsFailedMatchBytes(
	comparingBytes []byte,
) bool

func (*LazyRegex) IsInvalid added in v1.3.34

func (it *LazyRegex) IsInvalid() bool

func (*LazyRegex) IsMatch added in v1.3.34

func (it *LazyRegex) IsMatch(
	comparing string,
) bool

func (*LazyRegex) IsMatchBytes added in v1.3.34

func (it *LazyRegex) IsMatchBytes(
	comparingBytes []byte,
) bool

func (*LazyRegex) IsNull added in v1.3.34

func (it *LazyRegex) IsNull() bool

func (*LazyRegex) IsUndefined added in v1.3.34

func (it *LazyRegex) IsUndefined() bool

func (*LazyRegex) MatchError added in v1.3.34

func (it *LazyRegex) MatchError(matchingPattern string) error

func (*LazyRegex) MatchUsingFuncError added in v1.3.34

func (it *LazyRegex) MatchUsingFuncError(
	comparing string,
	matchFunc RegexValidationFunc,
) error

MatchUsingFuncError

creates new regex using lock
and then calls match.
On condition mismatch returns error
or else nil

func (*LazyRegex) MustBeSafe added in v1.3.34

func (it *LazyRegex) MustBeSafe()

func (*LazyRegex) OnRequiredCompiled added in v1.3.34

func (it *LazyRegex) OnRequiredCompiled() error

func (*LazyRegex) OnRequiredCompiledMust added in v1.3.34

func (it *LazyRegex) OnRequiredCompiledMust()

func (*LazyRegex) Pattern added in v1.3.34

func (it *LazyRegex) Pattern() (pattern string)

func (*LazyRegex) String added in v1.3.34

func (it *LazyRegex) String() (pattern string)

type RegexValidationFunc added in v0.9.5

type RegexValidationFunc func(regex *regexp.Regexp, lookingTerm string) bool

Jump to

Keyboard shortcuts

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