use strict;
my $str = 'NetRange: 2001:4860:: - 2001:4860:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF
CIDR: 2001:4860::/32
NetName: GOOGLE-IPV6
NetHandle: NET6-2001-4860-1
Parent: ARIN-004 (NET6-2001-4800-0)
NetType: Direct Allocation
OriginAS: AS15169
Organization: Google LLC (GOGL)
RegDate: 2005-03-14
Updated: 2012-02-24
Ref: https://rdap.arin.net/registry/ip/2001:4860::
OrgName: Google LLC
OrgId: GOGL
Address: 1600 Amphitheatre Parkway
City: Mountain View
StateProv: CA
PostalCode: 94043
Country: US
RegDate: 2000-03-30
Updated: 2019-10-31
Comment: Please note that the recommended way to file abuse complaints are located in the following links.
Comment:
Comment: To report abuse and illegal activity: https://www.google.com/contact/
Comment:
Comment: For legal requests: http://support.google.com/legal
Comment:
Comment: Regards,
Comment: The Google Team
Ref: https://rdap.arin.net/registry/entity/GOGL
OrgTechHandle: ZG39-ARIN
OrgTechName: Google LLC
OrgTechPhone: +1-650-253-0000
OrgTechEmail: arin-contact@google.com
OrgTechRef: https://rdap.arin.net/registry/entity/ZG39-ARIN
OrgAbuseHandle: ABUSE5250-ARIN
OrgAbuseName: Abuse
OrgAbusePhone: +1-650-253-0000
OrgAbuseEmail: network-abuse@google.com
OrgAbuseRef: https://rdap.arin.net/registry/entity/ABUSE5250-ARIN
RNOCHandle: ZG39-ARIN
RNOCName: Google LLC
RNOCPhone: +1-650-253-0000
RNOCEmail: arin-contact@google.com
RNOCRef: https://rdap.arin.net/registry/entity/ZG39-ARIN
RTechHandle: ZG39-ARIN
RTechName: Google LLC
RTechPhone: +1-650-253-0000
RTechEmail: arin-contact@google.com
RTechRef: https://rdap.arin.net/registry/entity/ZG39-ARIN
RAbuseHandle: ZG39-ARIN
RAbuseName: Google LLC
RAbusePhone: +1-650-253-0000
RAbuseEmail: arin-contact@google.com
RAbuseRef: https://rdap.arin.net/registry/entity/ZG39-ARIN';
my $regex = qr/([^\n\r:]*)(:[ \t])[ \t]*([^\n\r]*)/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