Documentation
¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Compile ¶
Compile takes a regular expression and a custom lookup struct that should match the named groups in the regexp.
`lookup` should always be a pointer to a struct with only exported `int` properties.
Example ¶
package main import ( "fmt" "github.com/lunarway/release-manager/internal/regexp" ) func main() { var lookup = struct { FirstPart int SecondPart int }{} re, err := regexp.Compile(`(?P<FirstPart>.+)-(?P<SecondPart>.+)`, &lookup) // Handle err or use MustCompile if err != nil { panic(err) } matches := re.FindStringSubmatch("some-message") if matches == nil { panic("no match") } fmt.Println(matches[lookup.FirstPart], matches[lookup.SecondPart]) }
Output: some message
func MustCompile ¶
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.