https://github.com/jsumners/go-reggie
A wrapper on top of regexp.Regexp that provides utility methods for accessing named capture group results.
https://github.com/jsumners/go-reggie
go golang regex regular-expression
Last synced: 20 days ago
JSON representation
A wrapper on top of regexp.Regexp that provides utility methods for accessing named capture group results.
- Host: GitHub
- URL: https://github.com/jsumners/go-reggie
- Owner: jsumners
- License: mit
- Created: 2023-04-04T14:38:04.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2023-04-04T15:37:12.000Z (over 3 years ago)
- Last Synced: 2025-01-26T07:07:49.482Z (over 1 year ago)
- Topics: go, golang, regex, regular-expression
- Language: Go
- Homepage:
- Size: 4.88 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
- License: LICENSE
Awesome Lists containing this project
README
# Reggie
A simple wrapper on top of [`regexp.Regexp`](https://pkg.go.dev/regexp#Regexp)
to make working with named capture groups easier.
See [example_basic_test.go](./example_basic_test.go) for a full example.
## Install
```sh
$ go get github.com/jsumners/go-reggie
```
## Example
```go
package main
import "github.com/jsumners/go-reggie"
import "fmt"
func main() {
regex := reggie.MustCompile(`(?P\w{3})`)
matches := regex.FindStringSubmatch("bar")
if matches == nil {
panic("💥")
}
foo := regex.SubmatchWithName("foo")
fmt.Println(foo)
// Output:
// bar
}
```