Skip to content

Commit

Permalink
Add function to sub in . and @
Browse files Browse the repository at this point in the history
  • Loading branch information
jacksongoode committed Apr 19, 2024
1 parent 855c777 commit a943feb
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions pkg/strings.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down

0 comments on commit a943feb

Please sign in to comment.