Go bindings for the Oniguruma regex library, a powerful and mature regular expression library with support for a wide range of character sets and language syntaxes. Oniguruma is written in C.
Dual-licensed under MIT or the UNLICENSE.
Prerequisites:
In order to install onig-go, you need to have the Oniguruma library installed on your system.
You can install it using Homebrew:
brew install oniguruma
Or on Ubuntu you can install it using apt:
sudo apt install libonig-dev libonig5
Installation:
To install onig-go, use the following command:
go get github.com/tmikus/onig-go
package main
import (
"fmt"
"github.com/tmikus/onig-go"
)
func main() {
regex, _ := onig.NewRegex("e(l+)")
captures, _ := regex.Captures("hello")
for text := range captures.All() {
fmt.Println(text)
}
}
For more examples, see the regex_test.go file.
The API documentation is available at https://pkg.go.dev/github.com/tmikus/onig-go.