1
0
mirror of https://github.com/duke-git/lancet.git synced 2026-02-06 21: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

@@ -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]
}