use strict;
my $str = 'The cost of this car with a 3.5 litre engine, is €2,927.100, or $3 271.32. In Sweden that would be around 27000kr. I would have to work overtime for 215 days to save the money for that, even though my job in the Czech Republic pays 436.5Kč an hour, and I can save 10% percent of that. My buddy in Japan, bought one for ¥357014.83
Rs. 2000 , Rs.2000 , Rs 20,000.00 ,20,000 INR 200.25 INR
It was just pointed out to me that in France, amounts are written with the Euro-sign post-fixed, like 2 927,10€ or 2 927.10€ or 2927,10€ or 2927.10€.';
my $regex = qr/(Rs.|[$£€¥₹])?\s*(\d{1,3}(?:[, ]?\d{1,3})?(?:.\d+)?)(?(1)|\s*(kr\.?|Kč|INR|€))/p;
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