feat: add RegexMatchAllGroups

This commit is contained in:
dudaodong committed 2024-09-06 14:19:57 +08:00
1 parent 93be25920f
commit 90e5a0bfb2
5 files changed
+138 -2

No files matched your search

+8
View File
@@ -727,3 +727,11 @@ func TemplateReplace(template string, data map[string]string) string {
return result
}
// RegexMatchAllGroups Matches all subgroups in a string using a regular expression and returns the result.
// Play: todo
func RegexMatchAllGroups(pattern, str string) [][]string {
re := regexp.MustCompile(pattern)
matches := re.FindAllStringSubmatch(str, -1)
return matches
}