package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`(?ms)(RPA\s1:).+?Initiator\sID:\s(?<RPA1Initiator>[^ ]*)`)
var str = `SITE_VPLEX:
RPAs:
RPA 1:
Version: 4.1.SP1.P1(h.167)
WAN IP: 000.000.000.000
RPA LAN IPv4: 000.000.000.000
RPA LAN IPv6:N/A
iSCSI interface IPs: None
Interfaces:
Type: FC
Initiator ID: 50012481006bexxx
Type: FC
Initiator ID: 50012481006bexxx
Type: FC
Initiator ID: 50012481006bexxx
Type: FC
Initiator ID: 50012481006bexxx
Hardware details:
Hardware type: Intel Corporation S2600GZ GEN5
Adapter type: 2564
Vendor: Intel Corporation
Hardware Serial ID: FC6RP133000229_00000000002_FFF
Hardware Platform: Intel Corporation S2600GZ GEN5
Amount of memory: 16269416 KB
Number of CPUs: 12
RPA 2:
Version: 4.1.SP1.P1(h.167)
WAN IP: 000.000.000.000
RPA LAN IPv4: 000.000.000.000
RPA LAN IPv6:N/A
iSCSI interface IPs: None
Interfaces:
Type: FC
Initiator ID: 50012481006bdxxx
Type: FC
Initiator ID: 50012481006bdxxx
Type: FC
Initiator ID: 50012481006bdxxx
Type: FC
Initiator ID: 50012481006bdxxx
Hardware details:
Hardware type: Intel Corporation S2600GZ GEN5
Adapter type: 2564
Vendor: Intel Corporation
Hardware Serial ID: FC6RP133000135_0000000000_FFF
Hardware Platform: Intel Corporation S2600GZ GEN5
Amount of memory: 16269416 KB
Number of CPUs: 12`
for i, match := range re.FindAllString(str, -1) {
fmt.Println(match, "found at index", i)
}
}
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/