go: cuelang.org/go/pkg/regexp Index | Files

package regexp

import "cuelang.org/go/pkg/regexp"


Package Files

manual.go pkg.go regexp.go

func Find Uses

func Find(pattern, s string) (string, error)

Find returns a string holding the text of the leftmost match in s of the regular expression. It returns bottom if there was no match.

func FindAll Uses

func FindAll(pattern, s string, n int) ([]string, error)

FindAll returns a list of all successive matches of the expression. It matches successive non-overlapping matches of the entire expression. Empty matches abutting a preceding match are ignored. The return value is a list containing the successive matches. The integer argument n indicates the maximum number of matches to return for n >= 0, or all matches otherwise. It returns bottom for no match.

func FindAllNamedSubmatch Uses

func FindAllNamedSubmatch(pattern, s string, n int) ([]map[string]string, error)

FindAllNamedSubmatch is like FindAllSubmatch, but returns a map with the named used in capturing groups. See FindNamedSubmatch for an example on how to use named groups.

func FindAllSubmatch Uses

func FindAllSubmatch(pattern, s string, n int) ([][]string, error)

FindAllSubmatch finds successive matches as returned by FindSubmatch, observing the rules of FindAll. It returns bottom for no match.

func FindNamedSubmatch Uses

func FindNamedSubmatch(pattern, s string) (map[string]string, error)

FindNamedSubmatch is like FindSubmatch, but returns a map with the names used in capturing groups.


   regexp.MapSubmatch(#"Hello (?P<person>\w*)!"#, "Hello World!")
   [{person: "World"}]

func FindSubmatch Uses

func FindSubmatch(pattern, s string) ([]string, error)

FindSubmatch returns a list of strings holding the text of the leftmost match of the regular expression in s and the matches, if any, of its subexpressions. Submatches are matches of parenthesized subexpressions (also known as capturing groups) within the regular expression, numbered from left to right in order of opening parenthesis. Submatch 0 is the match of the entire expression, submatch 1 the match of the first parenthesized subexpression, and so on. It returns bottom for no match.

func Match Uses

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

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.

func QuoteMeta Uses

func QuoteMeta(s string) string

QuoteMeta returns a string that escapes all regular expression metacharacters inside the argument text; the returned string is a regular expression matching the literal text.

func Valid Uses

func Valid(pattern string) (bool, error)

Valid reports whether the given regular expression is valid.

Package regexp imports 4 packages (graph) and is imported by 2 packages. Updated 2021-01-26. Refresh now. Tools for package owners.