Documentation ¶
Overview ¶
regex is a wrapper for the standard regexp package. It automates the regexp.Compile process for you.
Index ¶
- func CacheRegex(regex string) error
- func CheckRegex(regex string) error
- func Cleanup()
- func Count() int
- func FindAllString(src, regex string) ([]string, error)
- func FindAllStringSubmatch(src, regex string) ([][]string, error)
- func MatchString(src, regex string) (bool, error)
- func ReplaceAllString(src, regex, replace string) (string, error)
- func ReplaceAllStringFunc(src, regex string, replace func(s string) string) (string, error)
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FindAllString ¶
FindAllString returns a slice of all strings holding the text of the leftmost match in src of the regular expression. If there is no match, the return value is nil. It will be empty if the regular expression successfully matches an empty string.
func FindAllStringSubmatch ¶
FindAllStringSubmatch returns a slice of a slice of strings holding the text of the leftmost match of the regular expression in src and the matches. A return value of nil indicates no match.
func MatchString ¶
MatchString reports whether the string src contains any match of the regular expression.
func ReplaceAllString ¶
ReplaceAllString returns a copy of src, replacing matches of the regular expression with the replacement string replace. Inside replace, $ signs are interpreted as in Expand, so for instance $1 represents the text of the first submatch.
Example ¶
package main import ( "fmt" "simonwaldherr.de/go/golibs/regex" ) func main() { str, _ := regex.ReplaceAllString("FooBaR LoReM IpSuM", "[a-z]", "") fmt.Print(str) }
Output: FBR LRM ISM
func ReplaceAllStringFunc ¶
ReplaceAllStringFunc returns a copy of src in which all matches of the regular expression have been replaced by the return value of function replace applied to the matched substring. The replacement returned by replace is substituted directly, without using Expand.
Types ¶
This section is empty.