wildcard

package
v3.11.0 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2026 License: AGPL-3.0 Imports: 2 Imported by: 17 modules, 21 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Has added in v3.2.2

func Has(pattern string) bool

Has returns true if the input pattern has a wildcard (pattern).

func Match

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

Match - finds whether the text matches/satisfies the pattern string. supports '*' and '?' wildcards in the pattern string. unlike path.Match(), considers a path as a flat name space while matching the pattern. The difference is illustrated in the example here https://play.golang.org/p/Ega9qgD4Qz .

func MatchAsPatternPrefix

func MatchAsPatternPrefix(pattern, text string) bool

MatchAsPatternPrefix matches text as a prefix of the given pattern. Examples:

| Pattern | Text    | Match Result |
====================================
| abc*    | ab      | True         |
| abc*    | abd     | False        |
| abc*c   | abcd    | True         |
| ab*??d  | abxxc   | True         |
| ab*??d  | abxc    | True         |
| ab??d   | abxc    | True         |
| ab??d   | abc     | True         |
| ab??d   | abcxdd  | False        |

This function is only useful in some special situations.

func MatchSimple

func MatchSimple(pattern, name string) bool

MatchSimple - finds whether the text matches/satisfies the pattern string. supports '*' wildcard in the pattern and ? for single characters. Only difference to Match is that `?` at the end is optional, meaning `a?` pattern will match name `a`.

Types

This section is empty.

Jump to

Keyboard shortcuts

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