use strict;
my $str = 'Subject:
Security ID:
Account Name:
Account Domain:
Logon ID:
Logon Type: 3
New Logon:
Security ID: ABC\\SH07
Account Name: SH07
Account Domain: ABC
Logon ID: 0xEB7A5403
Event in sequence: 1 of 1
Group Membership:
ABC\\Domain Users
Everyone
BUILTIN\\Users
NT AUTHORITY\\NETWORK
NT AUTHORITY\\Authenticated Users
NT AUTHORITY\\This Organization
ABC\\FS-ABCDEFG-Workspaces_CS-Production-WIP_MODIFY
ABC\\FS-ABCDEFG-Workspaces_CS-EntertainmentDesign-WIP_READ
ABC\\FS-ABCDEFG-Wspaces_CS-Print-WIP_READ
ABC\\Workstations-Desktop-Add Remove
ABC\\FS-ABCDEFG-Wpaces_CS-Imagery-WIP_READ
Authentication authority asserted identity
ABC\\APP-JDE-123';
my $regex = qr/Group\sMembership:\s+(([A-Za-z0-9-_]+\\)((?<test>[A-Za-z0-9-_ ]+))\s+)/mp;
if ( $str =~ /$regex/g ) {
print "Whole match is ${^MATCH} and its start/end positions can be obtained via \$-[0] and \$+[0]\n";
# print "Capture Group 1 is $1 and its start/end positions can be obtained via \$-[1] and \$+[1]\n";
# print "Capture Group 2 is $2 ... and so on\n";
}
# ${^POSTMATCH} and ${^PREMATCH} are also available with the use of '/p'
# Named capture groups can be called via $+{name}
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 Perl, please visit: http://perldoc.perl.org/perlre.html