pattern

package
v1.20.0 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2026 License: MIT Imports: 4 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package pattern holds the regular expressions that gohai keeps in package variables. regexp.MustCompile panics on a bad expression, and code in gohai does not panic. New compiles without a panic: a bad expression gives a Pattern that matches nothing, and Errors reports it. A test that links every collector checks that Errors is empty, so a bad expression fails the build of the tests, not a host.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Errors

func Errors() error

Errors returns the errors of each expression that New could not compile, joined, or nil when each one compiled.

Types

type Pattern

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

Pattern is a compiled regular expression. A Pattern whose expression did not compile matches nothing.

func New

func New(
	expr string,
) *Pattern

New compiles expr. When expr does not compile, New records the error for Errors and returns a Pattern that matches nothing.

func (*Pattern) FindAllString

func (p *Pattern) FindAllString(
	s string,
	n int,
) []string

FindAllString returns up to n successive matches in s, or all of them when n is negative, or nil when there is no match.

func (*Pattern) FindAllStringSubmatch

func (p *Pattern) FindAllStringSubmatch(
	s string,
	n int,
) [][]string

FindAllStringSubmatch returns up to n successive matches in s and their submatches, or all of them when n is negative, or nil when there is no match.

func (*Pattern) FindStringSubmatch

func (p *Pattern) FindStringSubmatch(
	s string,
) []string

FindStringSubmatch returns the leftmost match in s and its submatches, or nil when there is no match.

func (*Pattern) FindSubmatch

func (p *Pattern) FindSubmatch(
	b []byte,
) [][]byte

FindSubmatch returns the leftmost match in b and its submatches, or nil when there is no match.

func (*Pattern) MatchString

func (p *Pattern) MatchString(
	s string,
) bool

MatchString reports whether s contains a match of the pattern.

func (*Pattern) ReplaceAllString

func (p *Pattern) ReplaceAllString(
	s string,
	repl string,
) string

ReplaceAllString returns s with each match replaced by repl, which can name submatches as in regexp.Regexp.Expand. A pattern that matches nothing returns s unchanged.

Jump to

Keyboard shortcuts

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