beagle

package module
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 12, 2019 License: MIT Imports: 2 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

Beagle

A super simple regexp wrapper to make things more digestible for the average usecase.

Example Usage

package main

import (
    "fmt"

    "github.com/DaiHasso/beagle"
)

func main() {
    regex := MustRegex(`(?P<thing>\S+) (are|is) (?P<difficulty>\S+)`)

    result := regex.Match(
        "I heard that go regexps are hard! But maybe it is easy.",
    )

    fmt.Printf(
        "Actually %s %s %s\n",
        result.NamedGroup("thing")[0],
        result.UnamedGroups()[0],
        result.NamedGroup("difficulty")[1],
    )
}

Will result in:

Actually regexps are easy.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Regex

type Regex struct {
	// contains filtered or unexported fields
}

func MakeBetter

func MakeBetter(regex *regexp.Regexp) *Regex

func MakeRegex

func MakeRegex(regex string) (*Regex, error)

func MustRegex

func MustRegex(regex string) *Regex

func (Regex) Match

func (self Regex) Match(target string) *Result

type Result

type Result struct {
	// contains filtered or unexported fields
}

func (Result) MatchedSubstrings

func (self Result) MatchedSubstrings() []string

func (Result) NamedGroup

func (self Result) NamedGroup(key string) []string

func (Result) UnamedGroups

func (self Result) UnamedGroups() []string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL