Skip to content

Latest commit

 

History

History
34 lines (25 loc) · 983 Bytes

README.md

File metadata and controls

34 lines (25 loc) · 983 Bytes

Glob to RegExp

Glob string to regexp string conversion in golang

Usage

package example

urlGlob := "{http,https}://example.com/**"
// converts to ^(http|https):\/\/example\.com\/(?:(?:[^/]*(?:/|$))*)$
urlRe := globre.RegexFromGlobWithOptions(
	urlGlob, globre.Options{
		Extended:  true,
		GlobStar:  true,
		Delimiter: '/',
	})
urlRegexp := regexp.MustCompile(urlRe)
urlRegexp.MatchString("https://example.com/index.htm")

Options

The conversion to regexp can be modified using globre.Options.

Attr Type Desc
Delimiter rune Delimiter used for tokenising the compared string
Extended bool Enable extended globs, supporting classes, etc.
GlobStar bool Enables "double-star" match for one or more tokens

License

Please see LICENSE and LICENSE-THIRD-PARTY.