Skip to content

Glob string to regexp string conversion in golang

License

MIT, Unknown licenses found

Licenses found

MIT
LICENSE
Unknown
LICENSE-THIRD-PARTY.md
Notifications You must be signed in to change notification settings

redmatter/go-globre

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

Glob string to regexp string conversion in golang

Topics

Resources

License

MIT, Unknown licenses found

Licenses found

MIT
LICENSE
Unknown
LICENSE-THIRD-PARTY.md

Stars

Watchers

Forks

Packages

No packages published

Languages