use strict;
my $str = '
# Hello 54.217.223.119. Your session has been logged.<br />
#<br />
# Copyright (c) 2002 - 2014 by DK Hostmaster A/S<br />
# <br />
# The data in the DK Whois database is provided by DK Hostmaster A/S<br />
# for information purposes only, and to assist persons in obtaining<br />
# information about or related to a domain name registration record.<br />
# We do not guarantee its accuracy. We will reserve the right to remove<br />
# access for entities abusing the data, without notice.<br />
# <br />
# Any use of this material to target advertising or similar activities<br />
# are explicitly forbidden and will be prosecuted. DK Hostmaster A/S<br />
# requests to be notified of any such activities or suspicions thereof.<br />
Domain: dr.dk<br />
DNS: dr.dk<br />
Registered: 1998-03-11<br />
Expires: 2015-03-31<br />
Registration period: 1 year<br />
VID: no<br />
Status: Active<br />
Registrant<br />
Handle: D5109-DK<br />
Name: DR<br />
Address: DR-Byen, Emil Holms kanal 20<br />
Postalcode: 0999<br />
City: København C<br />
Country: DK<br />
Phone: +4535203661<br />
Administrator<br />
Handle: DH4991-DK<br />
Name: DR<br />
Attention: DR Hostmaster<br />
Address: DR-Byen, Emil Holms kanal 20<br />
Postalcode: 0999<br />
City: København C<br />
Country: DK<br />
Phone: +4535203660<br />
Nameservers<br />
Hostname: dns101.telia.com<br />
Handle: TA632-DK<br />
Hostname: dns102.telia.com<br />
Handle: TA632-DK<br />
Hostname: ns01.dr.dk<br />
Handle: DR3450-DK<br />';
my $regex = qr/^[\#]$/ip;
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