use strict;
my $str = 'CA9458541531029720 0 Õ € Q X a j r t „€ ‘ – JOSEAREVALO6156479343/31/1993F2786386CA Xñ
CA9458570739857370 0 Õ¥ MaryjhuneBragado5609341351/17/1982b9356556CA `ñ
CA9458570741955170 0 Õ € R X a j r t „€ ‘ – jameswalker4331149435/15/1959b9234757CA dñ
CA9066056240517090 0 ìÔ € R U ^ g o q €Œ Ž “ BRIANTIK5458156197/16/1975B3342077CA 4ñ
CA9458031025531130 0 íÔ U [ d m u w ‡€ ’ — ¡ TRINIDADSANTOS5533361392/19/1959N5248608CA 5ñ
CA9458292533964780 0 îÔ € R [ d m u w ‡€‘ “ ˜ ¢ adelagutierrez5548982784/13/1971a8350300CA 6ñ
CA9066056290801050 0 ïÔ S U ^ h p r ‚€‹ ’ œ EDMONDYU57208906011/30/1953N3297882CA 7ñ
CA9458292564880620 0 ðÔ € Q X a j q s ƒ€Œ Ž “ KyleEastman6265480213/15/1990D989010CA 8ñ
CA9458292596399750 0 ñÔ R W ` h p r ‚€ ” ž dianegomez5472938769/7/1963c0290788CA 9ñ
CA9066056220118960 0 òÔ € S X a i q s ƒ€Œ Ž “ ALICIADAVIS5695934389/4/1962C0388640CA :ñ
CA9458292520067250 0 óÔ S Y b j q s ƒ€Ž • Ÿ BeckiiBarton3098605121/5/1968E787241CA ;ñ
CA9066056262386540 0 ôÔ € R X a k s u …€Œ Ž “ DAVIDFOSTER62122280512/21/1988d6853927CA <ñ
CABAZONCA9223095184920980 0 õÔ S \\ e n v x ˆ€‘ “ ˜ ¢ kelleycarpenter5494747231/22/1962n8892633CA =ñ
CA9458292558065680 0 öÔ € Q U ^ g o q €† ˆ — carlneal4302148345/10/1971a2722482CA >ñ
CA9530720923065470 0 ÷Ô V ] f o w y ‰€’ ” ™ £ constancedobbins2472191646/22/1966d3711758CA ?ñ
CA9458251043273810 0 øÔ € U Z c l u w ‡€’ ” ™ £ katalinagomez61940050311/3/1989e19556116CA @ñ
CA9066056223622510 0 ùÔ R W ` i q s ƒ€Œ Ž “ BryanKlein6000974524/18/1969F2898009CA Añ
CA9458292536237930 0 úÔ € R [ d l t v †€‘ “ ˜ ¢ davidvelasquez5513188625/2/1965a5657005CA Bñ
CA9066056292863440 0 ûÔ S [ d n v x ˆ€“ • š ¤ MiguelQuintero57135015811/19/1969A4071434CA Cñ
CA9066056286159880 0 üÔ € Q W ` i q s ƒ€Œ Ž “ johnlarson5707996146/14/1967c3807957CA Dñ
CA9458392582819850 0 ýÔ S Z c l t v †€ ‘ – cherylkovacik3417255601/16/1960C3577212CA Eñ
CA9458392573576640 0 þÔ € Q X a k s u …€ ’ — ¡ SaraTurcios62405747711/21/1984D6159809CA Fñ
CA9066056285295550 0 ÿÔ V ^ g p x z Š€• — œ ¦ GENEVIEVEWILLIAMS5554784895/11/1961N8713815CA Gñ
CA9066056278752300 0 Õ € R Y b l t v †€ ‘ – dianawhitney56963328110/19/1964c2511736CA Hñ
CA9458392582846560 0 Õ Q U ^ f n p €€‹ ’ œ Rubyrojo5505175434/7/1977b6078175CA Iñ
CA9066056266591570 0 Õ € S Y b k s u …€Œ Ž “ DebbieWallis5521147635/22/1962N8062380CA Jñ
CA9223095184920980 0 Õ T Y b j r t „€ ‘ – caridadavila5604585905/7/1976b3393184CA Kñ
CA9066033324713270 0 Õ € P T ] e m o €ˆ Š ™ TomMini5568607044/7/1952E0158545CA Lñ
CA9458351055771600 0 Õ Q V _ h p r ‚€‹ ’ œ JohnCrain5567459788/19/1948R0055874CA Mñ
CA9458392520042480 0 Õ € P T ] g o q €Š Œ ‘ › MANWONG54505011411/30/1962C5674431CA Nñ
CA9458351036739820 0 Õ Q W ` i q s ƒ€Ž • Ÿ josegarcia6201498175/11/1966c3174253CA Oñ
CA9066032333159770 0 Õ € S W ` i q s ƒ€Œ Ž “ danielsoto6187064407/21/1964b3054964CA Pñ
CA9211661989032070 0 Õ Q Z c l t v †€‘ “ ˜ ¢ kararay craig45539607110/6/1975B5902264CA Qñ';
my $regex = qr/(CA\d{16}).*([A-Za-z0-9].CA) /p;
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