use strict;
my $str = 'My acc reference is 123456
My reference number is 123-456
My a/c reference number is 123-4556A
A/c number is 123-3456
This is another ref. number: 123/567-2B
cat and kitten both refer to cats.
He made reference in his novel to the 1929 census.
This data uses information from the financial year 1992/93 and also makes references to 90/91 figures.
The background property refers to a hexidecimal colour, H102567.
My a/c reference number is 123/456';
my $regex = qr/(?<=a\/c|acc|account|ref|reference)\b\D+[0-9A-Za-z\-\\\/]+/imp;
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