Documentation
¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DeleteRegexGroup ¶
DeleteRegexGroup tries to retreive a regular expression group previously created by NewRegexGroup.
Example ¶
NewRegexGroup("test", `^\w+$`, `^Hello (?P<who>\w+).*$`)
result := DeleteRegexGroup("test")
fmt.Println(result)
Output: [^\w+$ ^Hello (?P<who>\w+).*$]
Example (Not_existing) ¶
result := DeleteRegexGroup("not existing")
fmt.Println(result)
Output: []
func GetRegexGroup ¶
GetRegexGroup tries to retreive a regular expression group previously created by NewRegexGroup.
Example ¶
// Create a group.
if _, err := NewRegexGroup("test", `^\w+$`, `^Hello (?P<who>\w+).*$`); err != nil {
fmt.Println("Invalid group definition", err)
}
result, match := MultiMatch("Hello world!", GetRegexGroup("test")...)
fmt.Printf("Matched group %d\n", match)
fmt.Println(result)
Output: Matched group 1 map[:Hello world! who:world]
func MultiMatch ¶
MultiMatch returns a map of matching elements from a list of regular expressions (returning the first matching element).
func NewRegexGroup ¶
NewRegexGroup cache compiled regex to avoid multiple interpretation of the same regex.
Example (With_error) ¶
// All supplied regular expressions must be valid.
if _, err := NewRegexGroup("test", `^\w+$`, `^Hello (?P(who)\w+).*$`); err != nil {
fmt.Println("Invalid group definition", err)
}
Output: Invalid group definition error parsing regexp: invalid or unsupported Perl syntax: `(?P`
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.