21
0
Fork 0
This commit is contained in:
Mike Schwörer 2023-01-15 02:05:05 +01:00
parent e1ae77a9db
commit e25912758e
Signed by: Mikescher
GPG Key ID: D3C7172E0A70F8CF
1 changed files with 5 additions and 0 deletions

View File

@ -8,6 +8,7 @@ type Regex interface {
MatchAll(haystack string) []RegexMatch MatchAll(haystack string) []RegexMatch
ReplaceAll(haystack string, repl string, literal bool) string ReplaceAll(haystack string, repl string, literal bool) string
ReplaceAllFunc(haystack string, repl func(string) string) string ReplaceAllFunc(haystack string, repl func(string) string) string
RemoveAll(haystack string) string
GroupCount() int GroupCount() int
} }
@ -71,6 +72,10 @@ func (w *regexWrapper) ReplaceAllFunc(haystack string, repl func(string) string)
return w.rex.ReplaceAllStringFunc(haystack, repl) return w.rex.ReplaceAllStringFunc(haystack, repl)
} }
func (w *regexWrapper) RemoveAll(haystack string) string {
return w.rex.ReplaceAllLiteralString(haystack, "")
}
// GroupCount returns the amount of groups in this match, does not count group-0 (whole match) // GroupCount returns the amount of groups in this match, does not count group-0 (whole match)
func (w *regexWrapper) GroupCount() int { func (w *regexWrapper) GroupCount() int {
return len(w.subnames) - 1 return len(w.subnames) - 1