From a943feb45bb708211776a8053209bea51e6ca3af Mon Sep 17 00:00:00 2001 From: Jackson Goode Date: Fri, 19 Apr 2024 16:45:27 -0700 Subject: [PATCH] Add function to sub in . and @ --- pkg/strings.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/pkg/strings.go b/pkg/strings.go index 413a6ae..72eded5 100644 --- a/pkg/strings.go +++ b/pkg/strings.go @@ -84,6 +84,18 @@ func ExtractEmailsFromText(text string) []string { // Find all email addresses in the text emails := re.FindAllString(text, -1) + // Replace the obfuscated "at" and "dot" with "@" and "." + replacementFunc := func(match string) string { + match = regexp.MustCompile(`[(\[{<]at[)\]}>]`).ReplaceAllString(match, "@") + match = regexp.MustCompile(`[(\[{<]dot[)\]}>]`).ReplaceAllString(match, ".") + return match + } + + // Apply the replacement function to each found email + for i, email := range emails { + emails[i] = replacementFunc(email) + } + return emails }