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

+14
View File
@@ -739,3 +739,17 @@ func ExampleTemplateReplace() {
// Output:
// Hello, my name is Bob, I'm 20 years old.
}
func ExampleRegexMatchAllGroups() {
pattern := `(\w+\.+\w+)@(\w+)\.(\w+)`
str := "Emails: john.doe@example.com and jane.doe@example.com"
result := RegexMatchAllGroups(pattern, str)
fmt.Println(result[0])
fmt.Println(result[1])
// Output:
// [john.doe@example.com john.doe example com]
// [jane.doe@example.com jane.doe example com]
}