regexp

package
v1.4.7 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2024 License: MIT Imports: 1 Imported by: 22

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Match

func Match(pattern string, s string) (matched bool)

Match reports whether the string s contains any match of the regular expression pattern. More complicated queries need to use Compile and the full Regexp interface.

Types

type RegExp

type RegExp interface {
	// Match reports whether the string s contains any match of the regular expression re.
	Match(s string) (matched bool)

	// Find is the 'All' version of Find; it returns a slice of all successive
	// matches of the expression, as defined by the 'All' description in the
	// package comment.
	// A return value of nil indicates no match.
	Find(s string) []string

	// FindN finds the matched value, max length n.
	FindN(s string, n int) []string

	// FindOne returns the first one matched value.
	FindOne(s string) string

	// Split slices s into substrings separated by the expression and returns a slice of
	// the substrings between those expression matches.
	Split(s string) []string

	// SplitN slices s into substrings separated by the expression and returns a slice of
	// the substrings between those expression matches.
	SplitN(s string, n int) []string

	// Replace returns a copy of src, replacing matches of the Regexp with the replacement text repl.
	// Inside repl, $ signs are interpreted as in Expand, so for instance $1 represents the text of the first submatch.
	Replace(src string, repl string) string

	// ReplaceFunc returns a copy of src in which all matches of the
	// Regexp have been replaced by the return value of function repl applied
	// to the matched substring. The replacement returned by repl is substituted
	// directly, without using Expand.
	ReplaceFunc(src string, repl func(string) string) string
}

RegExp is the regular expression interface.

func New

func New(pattern string) (RegExp, error)

New creates a new RegExp.

Jump to

Keyboard shortcuts

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