package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`Representatives:\s+(?<rep_name>.*)\(.*\)\s+((?<rep2_name>.*)?\s+\()?`)
var str = `----------------------------------------------
SESSION SUMMARY
----------------------------------------------
Representatives:
Amoz Abraham (ID: 23)
Jose Sandoval (ID: 25)
Customer Name: [Pinned] SOUTHLAWN02
Customer's Public IP: 174.110.83.140:56969
Customer's Private IP: 10.5.65.90
Session Start Time: 2020-05-15 17:03:22 US/Pacific
Session End Time: 2020-05-15 17:11:37 US/Pacific
Duration: 00:08:15
# Files Transferred: 0
# Files Moved: 0
# Files Deleted: 0
----------------------------------------------
SYSTEM INFORMATION RETRIEVED
----------------------------------------------
## General ##
Version: Windows 10 Pro x64
Computer Name: SOUTHLAWN02
System BIOS:
Processor 1 Info: Intel(R) Core(TM) i5-9500 CPU @ 3.00GHz
Processor 2 Info: Intel(R) Core(TM) i5-9500 CPU @ 3.00GHz
Processor 3 Info: Intel(R) Core(TM) i5-9500 CPU @ 3.00GHz
Processor 4 Info: Intel(R) Core(TM) i5-9500 CPU @ 3.00GHz
Processor 5 Info: Intel(R) Core(TM) i5-9500 CPU @ 3.00GHz
Processor 6 Info: Intel(R) Core(TM) i5-9500 CPU @ 3.00GHz
Default Browser: Google Chrome
Default Browser Version: 81.0.4044.138
Default Browser Location: C:\Program Files (x86)\Google\Chrome\Application\chrome.exe
Windows® Directory: C:\Windows
System Directory: C:\Windows\system32
Time Zone: Eastern Daylight Time
`
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/