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

package regexp

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

Index

Package Files

manual.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.

Example:

   regexp.MapSubmatch(#"Hello (?P<person>\w*)!"#, "Hello World!")
Output:
   [{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.

Package regexp imports 2 packages (graph). Updated 2019-12-07. Refresh now. Tools for package owners.