regexplus

package module
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2022 License: BSD-3-Clause Imports: 1 Imported by: 1

README

regexplus

Extended regexp functions, beyond the standard library

GitHub

Project Overview

Module github.com/shoenig/regexplus provides a package with extra functions for managing regular expressions, beyond what the standard library regexp provides.

Getting Started

The regexplus package can be installed by running

$ go get github.com/shoenig/regexplus
Example usage
re := regexp.MustCompile(`(?P<foo>[a-z]+)-(?P<bar>[0-9]+)`)
m := FindNamedSubmatches(re, "abc-123")
// m == Map{"foo":"abc", "bar":"123"}

Contributing

The github.com/shoenig/regexplus module is always improving with new features and error corrections. For contributing bug fixes and new features please file an issue.

License

The github.com/shoenig/regexplus module is open source under the BSD-3-Clause license.

Documentation

Overview

Package regexplus provides additional convenience functions over regexp.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Map

type Map map[string]string

A Map represents the key-value pairs generated by a regexp named group string matching. The keys are the names of named groups and the values are the matched strings.

func FindNamedSubmatches

func FindNamedSubmatches(re *regexp.Regexp, s string) Map

FindNamedSubmatches uses re to find named submatches of s, and returns a Map from keys (names of groups) to values (matches).

Example:

re := regexp.MustCompile(`(?P<foo>[a-z]+)-(?P<bar>[0-9]+)`)
m := FindNamedSubmatches(re, "abc-123")
m == Map{"foo":"abc", "bar":"123"}

Jump to

Keyboard shortcuts

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