1
0
mirror of https://github.com/duke-git/lancet.git synced 2026-02-04 12:52:28 +08:00

feat: add RegexMatchAllGroups

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

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
}