use strict;
my $str = 'FP Team,
Please install the Live database for store 1384. The updates have been completed.
• Store number – 1384
• StreetA – 1275 York Rd, Ste 21A
• City – Gettysburg
• State_id – PA
• Postal Code – 17325-7565
• Store Name – Gettysburg, PA
• Phone Number – (717) 420-8200
• Tax Rates
o Tax table 1 – 6.0000%
o Tax table 2 – 0.0000%
o Tax table 3 – 0.0000%
o Tax table 4 – 0.0000%
o Tax table 5 – N/A
• Artistree vendor – Kernersville
• Store Group – US.201308
• Store Zone number – 2030';
my $regex = qr/(?i)Store number – ([\d\D]*)\n.*StreetA – ([\d\D]*)\n.*City – ([\d\D]*)\n.*State_id – ([\d\D]*)\n.*Postal Code – ([\d\D]*)\n.*Store Name – ([\d\D]*)\n.*Phone Number – ([\d\D]*)\n.*Tax Rates.*\n.*Tax table 1 – ([\d\D]*)\n.*Tax table 2 – ([\d\D]*)\n.*Tax table 3 – ([\d\D]*)\n.*Tax table 4 – ([\d\D]*)\n.*Tax table 5 – ([\d\D]*)\n.*Artistree vendor – ([\d\D]*)\n.*Store Group – ([\d\D]*)\n.*Store Zone number – ([\d\D]*)/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