/go-reggie

A wrapper on top of regexp.Regexp that provides utility methods for accessing named capture group results.

Primary LanguageGoMIT LicenseMIT

Reggie

A simple wrapper on top of regexp.Regexp to make working with named capture groups easier.

See example_basic_test.go for a full example.

Install

$ go get github.com/jsumners/go-reggie

Example

package main

import "github.com/jsumners/go-reggie"
import "fmt"

func main() {
	regex := reggie.MustCompile(`(?P<foo>\w{3})`)
	matches := regex.FindStringSubmatch("bar")
	
	if matches == nil {
		panic("💥")
	}
		
	foo := regex.SubmatchWithName("foo")
	fmt.Println(foo)
	
	// Output:
	// bar
}