Golang matching: Difference between revisions

From wikinotes
Line 7: Line 7:
|-
|-
| <code>regexp</code> || https://pkg.go.dev/regexp
| <code>regexp</code> || https://pkg.go.dev/regexp
|-
| go regex syntax || https://pkg.go.dev/regexp/syntax
|-
|-
|}
|}

Revision as of 15:39, 4 July 2022

Documentation

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

Match (glob)

import "path"

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

Regexp

import "regexp"

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