use strict;
my $str = '//detail.tmall.com/item.htm?abtest=&pvid=42b3a520-35a1-47f8-abe8-572bef4a430f&pos=1&abbucket=&acm=03054.1003.1.2768562&id=604432657613&scm=1007.16862.95220.23864_0_0&utparam=%7B%22x_hestia_source%22%3A%2223864%22%2C%22x_object_type%22%3A%22item%22%2C%22x_mt%22%3A0%2C%22x_src%22%3A%2223864%22%2C%22x_pos%22%3A1%2C%22x_pvid%22%3A%2242b3a520-35a1-47f8-abe8-572bef4a430f%22%2C%22x_object_id%22%3A604432657613%7D';
my $regex = qr/(\&|\?)(id=\d+)/sp;
if ( $str =~ /$regex/ ) {
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