Golang matching

From wikinotes
Revision as of 17:01, 18 June 2022 by Will (talk | contribs) (Created page with " = Documentation = <blockquote> {| class="wikitable" |- | <code>path.Match</code> (glob match) || https://pkg.go.dev/path@go1.18.3#Match |- | <code>regexp</code> || https://pkg.go.dev/regexp |- |} </blockquote><!-- Documentation --> = Match (glob) = <blockquote> <syntaxhighlight lang="bash"> import "path" isTrue := path.Match("f*", "foo") // glob match </syntaxhighlight> </blockquote><!-- Match (glob) --> = Regexp = <blockquote> <syntaxhighlight lang="go"> import "re...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Documentation

path.Match (glob match) https://pkg.go.dev/path@go1.18.3#Match
regexp https://pkg.go.dev/regexp

Match (glob)

import "path"

isTrue := path.Match("f*", "foo")  // glob match

Regexp

import "regexp"

isTrue, err := regexp.Match("^[a-z]+$", "foobar")  // match