use strict;
my $str = '10.0.0.1
10.19.0.13
10.22.0.13
10.20.0.2
10.0.0.6
10.24.0.1
10.19.0.233
10.18.0.13
10.17.0.12
10.0.0.12
10.0.0.211
10.3.0.123
10.4.0.121
10.5.0.200
10.5.0.201
10.5.0.1
10.4.0.0
10.4.0.254
10.0.0.12
10.9.0.134
10.10.0.112
10.20.0.254
10.20.0.1
10.20.0.9
10.19.0.19
10.18.0.18
10.13.0.1
';
my $regex = qr/10\.(?:[0-9]|[0-1][0-9]?|20)\.0\.(?:25[0-4]|2[0-4][0-9]|1[0-9][0-9]|[2-9][0-9]|1[1-9]|[1-9])/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