package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`\S+\@\S+`)
var str = `From: Avanan
Sent: Thursday, December 5, 2024 2:39 PM
To: Support
Subject: Security event detected
Hello,
Please look at the details of the following anomaly event.
Details:
Dana@acme.com performed geo-suspicious events: logged in from United States (216.221.27.67) and after 1 minute logged in from United States (173.160.110.50)`
if len(re.FindStringIndex(str)) > 0 {
fmt.Println(re.FindString(str),"found at index",re.FindStringIndex(str)[0])
}
}
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for Golang, please visit: https://golang.org/pkg/regexp/